Wisepricer_Syncer - Version 1.1.3.8

Version Notes

Added
- reprice of configurable product to the lowest price of its children;
- if product has special price then special price field is going to be repriced

Download this release

Release Info

Developer Magento Core Team
Extension Wisepricer_Syncer
Version 1.1.3.8
Comparing to
See all releases


Code changes from version 1.1.3.7 to 1.1.3.8

app/code/local/Wisepricer/Syncer/Model/Reprice.php CHANGED
@@ -2,6 +2,8 @@
2
 
3
  class Wisepricer_Syncer_Model_Reprice extends Mage_Core_Model_Abstract{
4
 
 
 
5
  private function _getConnection($type = 'core_read'){
6
  return Mage::getSingleton('core/resource')->getConnection($type);
7
  }
@@ -34,6 +36,27 @@ class Wisepricer_Syncer_Model_Reprice extends Mage_Core_Model_Abstract{
34
 
35
  }
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  public function checkIfSkuExists($sku){
38
  $connection = $this->_getConnection('core_read');
39
  $sql = "SELECT COUNT(*) AS count_no FROM " . $this->_getTableName('catalog_product_entity') . " WHERE sku = ?";
@@ -58,29 +81,85 @@ class Wisepricer_Syncer_Model_Reprice extends Mage_Core_Model_Abstract{
58
 
59
  public function updatePricesBySku($prodArr){
60
  $connection = $this->_getConnection('core_write');
61
- $sku = $prodArr->sku;
62
- $newPrice = $prodArr->price;
 
 
 
 
 
 
 
63
  $productId = $this->_getIdFromSku($sku);
64
  $attributeId = $this->_getAttributeId();
 
 
 
 
 
 
65
 
66
  $sql = "UPDATE " . $this->_getTableName('catalog_product_entity_decimal') . " cped
67
  SET cped.value = ?
68
  WHERE cped.attribute_id = ?
69
  AND cped.entity_id = ?";
70
  $connection->query($sql, array($newPrice, $attributeId, $productId));
 
71
  }
72
 
73
  public function updatePricesById($prodArr){
74
  $connection = $this->_getConnection('core_write');
75
- $productId = $prodArr->sku;
76
- $newPrice = $prodArr->price;
 
 
 
 
 
 
 
77
  $attributeId = $this->_getAttributeId();
78
 
 
 
 
 
 
 
 
79
  $sql = "UPDATE " . $this->_getTableName('catalog_product_entity_decimal') . " cped
80
  SET cped.value = ?
81
  WHERE cped.attribute_id = ?
82
  AND cped.entity_id = ?";
83
  $connection->query($sql, array($newPrice, $attributeId, $productId));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  }
85
  }
86
  ?>
2
 
3
  class Wisepricer_Syncer_Model_Reprice extends Mage_Core_Model_Abstract{
4
 
5
+ private $_parrentIds=array();
6
+
7
  private function _getConnection($type = 'core_read'){
8
  return Mage::getSingleton('core/resource')->getConnection($type);
9
  }
36
 
37
  }
38
 
39
+ private function _getConfigurableIds($productId){
40
+
41
+ $parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild($productId);
42
+
43
+ foreach($parentIds as $parId) {
44
+
45
+ if(!in_array($parId,$this->_parrentIds)){
46
+ $this->_parrentIds[]=$parId;
47
+ }
48
+
49
+ }
50
+ }
51
+
52
+ private function _getSpecialPrice($prodId,$spAttrId){
53
+
54
+ $connection = $this->_getConnection('core_write');
55
+ $sql ="SELECT value FROM " . $this->_getTableName('catalog_product_entity_decimal') . " WHERE entity_id = ? AND attribute_id = ?";
56
+ $res=$connection->fetchOne($sql, array($prodId,$spAttrId));
57
+ return $res;
58
+ }
59
+
60
  public function checkIfSkuExists($sku){
61
  $connection = $this->_getConnection('core_read');
62
  $sql = "SELECT COUNT(*) AS count_no FROM " . $this->_getTableName('catalog_product_entity') . " WHERE sku = ?";
81
 
82
  public function updatePricesBySku($prodArr){
83
  $connection = $this->_getConnection('core_write');
84
+
85
+ if(!is_array($prodArr)){
86
+ $sku = $prodArr->sku;
87
+ $newPrice = $prodArr->price;
88
+ }else{
89
+ $sku = $prodArr['sku'];
90
+ $newPrice = $prodArr['price'];
91
+ }
92
+
93
  $productId = $this->_getIdFromSku($sku);
94
  $attributeId = $this->_getAttributeId();
95
+ $spAttributeId = $this->_getAttributeId('special_price');
96
+ $specialPrice = $this->_getSpecialPrice($productId,$spAttributeId);
97
+
98
+ if($specialPrice){
99
+ $attributeId= $spAttributeId;
100
+ }
101
 
102
  $sql = "UPDATE " . $this->_getTableName('catalog_product_entity_decimal') . " cped
103
  SET cped.value = ?
104
  WHERE cped.attribute_id = ?
105
  AND cped.entity_id = ?";
106
  $connection->query($sql, array($newPrice, $attributeId, $productId));
107
+ $this->_getConfigurableIds($productId);
108
  }
109
 
110
  public function updatePricesById($prodArr){
111
  $connection = $this->_getConnection('core_write');
112
+
113
+ if(!is_array($prodArr)){
114
+ $productId = $prodArr->sku;
115
+ $newPrice = $prodArr->price;
116
+ }else{
117
+ $productId = $prodArr['sku'];
118
+ $newPrice = $prodArr['price'];
119
+ }
120
+
121
  $attributeId = $this->_getAttributeId();
122
 
123
+ $spAttributeId = $this->_getAttributeId('special_price');
124
+ $specialPrice = $this->_getSpecialPrice($productId,$spAttributeId);
125
+
126
+ if($specialPrice){
127
+ $attributeId= $spAttributeId;
128
+ }
129
+
130
  $sql = "UPDATE " . $this->_getTableName('catalog_product_entity_decimal') . " cped
131
  SET cped.value = ?
132
  WHERE cped.attribute_id = ?
133
  AND cped.entity_id = ?";
134
  $connection->query($sql, array($newPrice, $attributeId, $productId));
135
+ $this->_getConfigurableIds($productId);
136
+ }
137
+
138
+ public function getParrentIds(){
139
+ return $this->_parrentIds;
140
+ }
141
+
142
+ public function repriceConfigurable($productId){
143
+ $product=Mage::getModel('catalog/product')->load($productId);
144
+ $childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
145
+ $minPrice=0;
146
+
147
+ foreach($childProducts as $child){
148
+ $childPrice=$child->getFinalPrice();
149
+
150
+ if($minPrice==0){
151
+ $minPrice=$childPrice;
152
+ }
153
+
154
+ if($childPrice<$minPrice){
155
+ $minPrice=$childPrice;
156
+ }
157
+ }
158
+ $prodArr =array();
159
+ $prodArr['sku'] =$productId;
160
+ $prodArr['price'] =$minPrice;
161
+ $this->updatePricesById($prodArr);
162
+ return $minPrice;
163
  }
164
  }
165
  ?>
app/code/local/Wisepricer/Syncer/controllers/Adminhtml/SyncerController.php CHANGED
@@ -41,6 +41,12 @@ class Wisepricer_Syncer_Adminhtml_SyncerController extends Mage_Adminhtml_Contro
41
  $lisensekey = $post['licensekey'];
42
  $website = $post['website'];
43
  $type = $post['product_type'];
 
 
 
 
 
 
44
 
45
  try {
46
  if (empty($lisensekey)) {
@@ -52,6 +58,7 @@ class Wisepricer_Syncer_Adminhtml_SyncerController extends Mage_Adminhtml_Contro
52
  $lisenceData->setLicensekey($lisensekey);
53
  $lisenceData->setWebsite($website);
54
  $lisenceData->setProduct_type($type);
 
55
  $lisenceData->save();
56
  }else{
57
  $model->setLicensekey($lisensekey)->save();
41
  $lisensekey = $post['licensekey'];
42
  $website = $post['website'];
43
  $type = $post['product_type'];
44
+ $reprConf = $post['reprice_configurable'];
45
+ if(!$reprConf){
46
+ $reprConf=0;
47
+ }else{
48
+ $reprConf=1;
49
+ }
50
 
51
  try {
52
  if (empty($lisensekey)) {
58
  $lisenceData->setLicensekey($lisensekey);
59
  $lisenceData->setWebsite($website);
60
  $lisenceData->setProduct_type($type);
61
+ $lisenceData->setReprice_configurable($reprConf);
62
  $lisenceData->save();
63
  }else{
64
  $model->setLicensekey($lisensekey)->save();
app/code/local/Wisepricer/Syncer/controllers/ProductsController.php CHANGED
@@ -438,6 +438,19 @@ class Wisepricer_Syncer_ProductsController extends Mage_Core_Controller_Front_Ac
438
 
439
  }
440
 
 
 
 
 
 
 
 
 
 
 
 
 
 
441
 
442
  Mage::log(print_r('finished repricing',true),null,'wplog.log');
443
  if($sucessCounter==0){
438
 
439
  }
440
 
441
+ $parrentsIds=$repriceModel->getParrentIds();
442
+ foreach($parrentsIds as $parId){
443
+ try{
444
+ $minPrice=$repriceModel->repriceConfigurable($parId);
445
+ $responseArr[]=array('sku'=>$parId,'price'=>$minPrice,'error_code'=>'0');
446
+ $sucessCounter++;
447
+ }catch (Exception $exc) {
448
+ $responseArr[]=array('sku'=>$parId,'error_code'=>'444','error_details'=>$exc->getMessage());
449
+ $failedCounter++;
450
+ }
451
+
452
+ }
453
+
454
 
455
  Mage::log(print_r('finished repricing',true),null,'wplog.log');
456
  if($sucessCounter==0){
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.7</version>
6
  <url>http://www.wisepricer.com/index.php</url>
7
  <modulename>Wisepricer Syncer</modulename>
8
  </Wisepricer_Syncer>
2
  <config>
3
  <modules>
4
  <Wisepricer_Syncer>
5
+ <version>1.1.3.8</version>
6
  <url>http://www.wisepricer.com/index.php</url>
7
  <modulename>Wisepricer Syncer</modulename>
8
  </Wisepricer_Syncer>
app/code/local/Wisepricer/Syncer/sql/syncer_setup/{mysql4-install-1.1.3.7.php → mysql4-install-1.1.3.8.php} RENAMED
File without changes
package.xml CHANGED
@@ -1,18 +1,20 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Wisepricer_Syncer</name>
4
- <version>1.1.3.7</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>WisePricer- Beat your competition</summary>
10
  <description>WisePricer is a new tool that allows you to Track &amp; monitor successful online retailers and update your store prices in real-time. With WisePricer you&#x2019;ll never get left behind the competition.</description>
11
- <notes>Added import/reprice by ID functionality</notes>
 
 
12
  <authors><author><name>Moshe</name><user>auto-converted</user><email>moshe@wisepricer.com</email></author></authors>
13
- <date>2012-12-05</date>
14
- <time>09:22:02</time>
15
- <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="5d32d93fd57060569c6788290c17796e"/><dir name="Adminhtml"><file name="SyncerController.php" hash="6a229900d705b0ee4335e37233c798e3"/></dir></dir><dir name="etc"><file name="config.xml" hash="9153a4792ff7069245d313a4fd0b03a6"/></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="Reprice.php" hash="9e4633dfd1e8de004014bc0ab873675b"/><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.7.php" hash="fcf864d92f3c71b0de06c0c5aef4dc3f"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Wisepricer_Syncer</name>
4
+ <version>1.1.3.8</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>WisePricer- Beat your competition</summary>
10
  <description>WisePricer is a new tool that allows you to Track &amp; monitor successful online retailers and update your store prices in real-time. With WisePricer you&#x2019;ll never get left behind the competition.</description>
11
+ <notes>Added
12
+ - reprice of configurable product to the lowest price of its children;
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>2012-12-16</date>
16
+ <time>11:52:43</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="ffe146a08ba6a9b11d3dbc55d14d83ae"/><dir name="Adminhtml"><file name="SyncerController.php" hash="e2bc96dc0a36913537cb029b2bdea577"/></dir></dir><dir name="etc"><file name="config.xml" hash="8547e6db2f48b0f1c4239f3d13199ca2"/></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="Reprice.php" hash="651a4a13e1584d3803aefe4461fe1514"/><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="fcf864d92f3c71b0de06c0c5aef4dc3f"/></dir></dir></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies/>
20
  </package>