Stuttme_PriceConvert - Version 1.0.1

Version Notes

add or remove a percentage to your products price

Download this release

Release Info

Developer Markus Antecki
Extension Stuttme_PriceConvert
Version 1.0.1
Comparing to
See all releases


Version 1.0.1

app/code/community/Stuttme/PriceConvert/Adminhtml/ConvertController.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of the STUTTGART MEDIA project.
4
+ *
5
+ * Stuttme_PriceConvert is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License version 3 as
7
+ * published by the Free Software Foundation.
8
+ *
9
+ * This script is distributed in the hope that it will be useful, but WITHOUT
10
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
+ *
13
+ * PHP version 5
14
+ *
15
+ * @category Stuttme
16
+ * @package Stuttme_PriceConvert
17
+ * @author STUTTGART MEDIA <mage@stuttgartmedia.de>
18
+ * @copyright 2012 STUTTGART MEDIA (http://www.stuttgartmedia.de). All rights served.
19
+ * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
20
+ * @version $Id:$
21
+ * @since 1.0.0
22
+ */
23
+
24
+ class Stuttme_PriceConvert_Adminhtml_ConvertController extends Mage_Adminhtml_Controller_Action
25
+ {
26
+ public function indexAction()
27
+ {
28
+ $this->loadLayout()->renderLayout();
29
+ }
30
+
31
+ public function postAction()
32
+ {
33
+ // get post data
34
+ $post = $this->getRequest()->getPost();
35
+ try {
36
+ if (empty($post)) {
37
+ Mage::throwException($this->__('Please fill percent field.'));
38
+ }
39
+ // convert percent
40
+ if($post['convert']['percent']) {
41
+ $percent = floatval(str_replace(",", ".", $post['convert']['percent']))/100+1;
42
+ $model = Mage::getModel('catalog/product');
43
+ $collection = $model->getCollection();
44
+ foreach($collection as $p) {
45
+ $cProduct = Mage::getModel("catalog/product");
46
+ $cProduct->load($p->getId());
47
+ // if minus option not set
48
+ if(!$post['convert']['minus']) {
49
+ $newPrice = round($cProduct->getPrice() * $percent, 2);
50
+ if($post['convert']['special_price'] && $cProduct->getSpecialPrice()) {
51
+ $newSpecialPrice = round($cProduct->getSpecialPrice() * $percent, 2);
52
+ }
53
+ } else {
54
+ $newPrice = round($cProduct->getPrice() / $percent, 2);
55
+ if($post['convert']['special_price'] && $cProduct->getSpecialPrice()) {
56
+ $newSpecialPrice = round($cProduct->getSpecialPrice() / $percent, 2);
57
+ }
58
+ }
59
+ $cProduct->setPrice($newPrice);
60
+ if($post['convert']['special_price'] && $newSpecialPrice) {
61
+ $cProduct->setSpecialPrice($newSpecialPrice);
62
+ }
63
+ $cProduct->save();
64
+ }
65
+ }
66
+ $message = $this->__('Your product prices has been updatet.');
67
+ Mage::getSingleton('adminhtml/session')->addSuccess($message);
68
+ } catch (Exception $e) {
69
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
70
+ }
71
+ $this->_redirect('*/*');
72
+ }
73
+ }
74
+ ?>
app/code/community/Stuttme/PriceConvert/Block/Convert.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of the STUTTGART MEDIA project.
4
+ *
5
+ * Stuttme_PriceConvert is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License version 3 as
7
+ * published by the Free Software Foundation.
8
+ *
9
+ * This script is distributed in the hope that it will be useful, but WITHOUT
10
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
+ *
13
+ * PHP version 5
14
+ *
15
+ * @category Stuttme
16
+ * @package Stuttme_PriceConvert
17
+ * @author STUTTGART MEDIA <mage@stuttgartmedia.de>
18
+ * @copyright 2012 STUTTGART MEDIA (http://www.stuttgartmedia.de). All rights served.
19
+ * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
20
+ * @version $Id:$
21
+ * @since 1.0.0
22
+ */
23
+
24
+ ?>
app/code/community/Stuttme/PriceConvert/Helper/Data.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of the STUTTGART MEDIA project.
4
+ *
5
+ * Stuttme_PriceConvert is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License version 3 as
7
+ * published by the Free Software Foundation.
8
+ *
9
+ * This script is distributed in the hope that it will be useful, but WITHOUT
10
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
+ *
13
+ * PHP version 5
14
+ *
15
+ * @category Stuttme
16
+ * @package Stuttme_PriceConvert
17
+ * @author STUTTGART MEDIA <mage@stuttgartmedia.de>
18
+ * @copyright 2012 STUTTGART MEDIA (http://www.stuttgartmedia.de). All rights served.
19
+ * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
20
+ * @version $Id:$
21
+ * @since 1.0.0
22
+ */
23
+
24
+ class Stuttme_PriceConvert_Helper_Data extends Mage_Core_Helper_Abstract {
25
+
26
+ }
27
+
28
+ ?>
app/code/community/Stuttme/PriceConvert/controllers/Adminhtml/ConvertController.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of the STUTTGART MEDIA project.
4
+ *
5
+ * Stuttme_PriceConvert is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License version 3 as
7
+ * published by the Free Software Foundation.
8
+ *
9
+ * This script is distributed in the hope that it will be useful, but WITHOUT
10
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
+ *
13
+ * PHP version 5
14
+ *
15
+ * @category Stuttme
16
+ * @package Stuttme_PriceConvert
17
+ * @author STUTTGART MEDIA <mage@stuttgartmedia.de>
18
+ * @copyright 2012 STUTTGART MEDIA (http://www.stuttgartmedia.de). All rights served.
19
+ * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3)
20
+ * @version $Id:$
21
+ * @since 1.0.0
22
+ */
23
+
24
+ class Stuttme_PriceConvert_Adminhtml_ConvertController extends Mage_Adminhtml_Controller_Action
25
+ {
26
+ public function indexAction()
27
+ {
28
+ $this->loadLayout()->renderLayout();
29
+ }
30
+
31
+ public function postAction()
32
+ {
33
+ // get post data
34
+ $post = $this->getRequest()->getPost();
35
+ try {
36
+ if (empty($post)) {
37
+ Mage::throwException($this->__('Please fill percent field.'));
38
+ }
39
+ // convert percent
40
+ if($post['convert']['percent']) {
41
+ $percent = floatval(str_replace(",", ".", $post['convert']['percent']))/100+1;
42
+ $model = Mage::getModel('catalog/product');
43
+ $collection = $model->getCollection();
44
+ foreach($collection as $p) {
45
+ $cProduct = Mage::getModel("catalog/product");
46
+ $cProduct->load($p->getId());
47
+ // if minus option not set
48
+ if(!$post['convert']['minus']) {
49
+ $newPrice = round($cProduct->getPrice() * $percent, 2);
50
+ if($post['convert']['special_price'] && $cProduct->getSpecialPrice()) {
51
+ $newSpecialPrice = round($cProduct->getSpecialPrice() * $percent, 2);
52
+ }
53
+ } else {
54
+ $newPrice = round($cProduct->getPrice() / $percent, 2);
55
+ if($post['convert']['special_price'] && $cProduct->getSpecialPrice()) {
56
+ $newSpecialPrice = round($cProduct->getSpecialPrice() / $percent, 2);
57
+ }
58
+ }
59
+ $cProduct->setPrice($newPrice);
60
+ if($post['convert']['special_price'] && $newSpecialPrice) {
61
+ $cProduct->setSpecialPrice($newSpecialPrice);
62
+ }
63
+ $cProduct->save();
64
+ }
65
+ }
66
+ $message = $this->__('Your product prices has been updatet.');
67
+ Mage::getSingleton('adminhtml/session')->addSuccess($message);
68
+ } catch (Exception $e) {
69
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
70
+ }
71
+ $this->_redirect('*/*');
72
+ }
73
+ }
74
+ ?>
app/code/community/Stuttme/PriceConvert/etc/config.xml ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Stuttme_PriceConvert>
5
+ <version>1.0.0</version>
6
+ </Stuttme_PriceConvert>
7
+ </modules>
8
+
9
+ <global>
10
+ <models>
11
+ <priceconvert>
12
+ <class>Stuttme_PriceConvert_Model</class>
13
+ <resourceModel>priceconvert_mysql4</resourceModel>
14
+ </priceconvert>
15
+ <priceconvert_mysql4>
16
+ <class>Stuttme_PriceConvert_Model_Mysql4</class>
17
+ </priceconvert_mysql4>
18
+ </models>
19
+ <blocks>
20
+ <priceconvert>
21
+ <class>Stuttme_PriceConvert_Block</class>
22
+ </priceconvert>
23
+ </blocks>
24
+ <helpers>
25
+ <priceconvert>
26
+ <class>Stuttme_PriceConvert_Helper</class>
27
+ </priceconvert>
28
+ </helpers>
29
+ </global>
30
+
31
+ <admin>
32
+ <routers>
33
+ <priceconvert>
34
+ <use>admin</use>
35
+ <args>
36
+ <module>Stuttme_PriceConvert</module>
37
+ <frontName>priceconvert</frontName>
38
+ </args>
39
+ </priceconvert>
40
+ </routers>
41
+ </admin>
42
+
43
+ <adminhtml>
44
+ <translate>
45
+ <modules>
46
+ <mage_adminhtml>
47
+ <files>
48
+ <priceconvert>Stuttme_PriceConvert.csv</priceconvert>
49
+ </files>
50
+ </mage_adminhtml>
51
+ </modules>
52
+ </translate>
53
+
54
+ <menu>
55
+ <catalog>
56
+ <children>
57
+ <priceconvert_adminform translate="title" module="priceconvert">
58
+ <title>Price Converter</title>
59
+ <action>priceconvert/adminhtml_convert</action>
60
+ </priceconvert_adminform>
61
+ </children>
62
+ </catalog>
63
+ </menu>
64
+
65
+ <acl>
66
+ <resources>
67
+ <admin>
68
+ <children>
69
+ <catalog>
70
+ <children>
71
+ <priceconvert_adminform>
72
+ <title>Price Convert</title>
73
+ </priceconvert_adminform>
74
+ </children>
75
+ </catalog>
76
+ </children>
77
+ </admin>
78
+ </resources>
79
+ </acl>
80
+
81
+ <layout>
82
+ <updates>
83
+ <priceconvert>
84
+ <file>priceconvert.xml</file>
85
+ </priceconvert>
86
+ </updates>
87
+ </layout>
88
+ </adminhtml>
89
+ </config>
app/design/adminhtml/default/default/layout/priceconvert.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <priceconvert_adminhtml_convert_index>
4
+ <update handle="priceconvert_config_index"/>
5
+ <reference name="content">
6
+ <block type="adminhtml/template" name="convert" template="priceconvert/convert.phtml"/>
7
+ </reference>
8
+ </priceconvert_adminhtml_convert_index>
9
+ </layout>
app/design/adminhtml/default/default/template/priceconvert/convert.phtml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <table cellspacing="0" class="grid-header">
3
+ <tr>
4
+ <td><h3><?=$this->__('PriceConvert')?></h3></td>
5
+ <td class="a-right">
6
+ <button onclick="convertForm.submit()" class="scalable save" type="button"><span><?=$this->__('convert now')?></span></button>
7
+ </td>
8
+ </tr>
9
+ </table>
10
+ </div>
11
+ <div class="entry-edit">
12
+ <form id="convert_form" name="convert_form" method="post" action="<?=$this->getUrl('*/*/post')?>">
13
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
14
+ <h4 class="icon-head head-edit-form fieldset-legend"><?=$this->__('Adds percentage value to price')?></h4>
15
+ <fieldset id="my-fieldset">
16
+ <table cellspacing="0" class="form-list">
17
+ <tr>
18
+ <td class="label"><?=$this->__('Percent')?>: <span class="required">*</span></td>
19
+ <td class="input-ele"><input class="input-text required-entry validate-number" name="convert[percent]" /></td>
20
+ </tr>
21
+ <tr>
22
+ <td class="label"><?=$this->__('Subtract')?>:</td>
23
+ <td class="input-ele"><input type="checkbox" name="convert[minus]" /></td>
24
+ </tr>
25
+ <tr>
26
+ <td class="label"><?=$this->__('Include special price')?>:</td>
27
+ <td class="input-ele"><input type="checkbox" name="convert[special_price]" /></td>
28
+ </tr>
29
+ </table>
30
+ </fieldset>
31
+ </form>
32
+ </div>
33
+ <script type="text/javascript">
34
+ var convertForm = new varienForm('convert_form');
35
+ </script>
app/etc/modules/Stuttme_PriceConvert.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Stuttme_PriceConvert>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Stuttme_PriceConvert>
8
+ </modules>
9
+ </config>
app/locale/de_DE/Stuttme_PriceConvert.csv ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ "PriceConvert","PriceConvert"
2
+ "convert now","jetzt konvertieren"
3
+ "Adds percentage value to price","Erhöht den Preis um einen von Ihnen angegebenen prozentualen Wert"
4
+ "Percent","Prozent"
5
+ "Please enter a valid number in this field.","Bitte geben Sie einen gültigen Zahlenwert ein."
6
+ "Your product prices has been updatet.","Ihre Produkt Preise wurden aktualisiert."
7
+ "Please fill percent field.","Bitte füllen Sie das Prozent Feld aus."
8
+ "Subtract","Abziehen"
9
+ "Include special price","Spezial Preis einbeziehen"
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Stuttme_PriceConvert</name>
4
+ <version>1.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/copyleft/gpl.html">GPL 3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>add or remove percentage value to your products price</summary>
10
+ <description>this module allows you to add or remove a percentage value to your products price or special price.&#xD;
11
+ e.g. your products were imported excl. tax, so you can add easily a percentage value to everay price.</description>
12
+ <notes>add or remove a percentage to your products price</notes>
13
+ <authors><author><name>Markus Antecki</name><user>mmmarkusa</user><email>ma@stuttgartmedia.de</email></author></authors>
14
+ <date>2012-07-14</date>
15
+ <time>17:37:50</time>
16
+ <contents><target name="magecommunity"><dir><dir name="Stuttme"><dir name="PriceConvert"><dir><dir name="Adminhtml"><file name="ConvertController.php" hash="c2f92c4ed528e0221fe0a1299bb0d50f"/></dir><dir name="Block"><file name="Convert.php" hash="1072d1207ce90096362dee91e21c4473"/></dir><dir name="Helper"><file name="Data.php" hash="5ce15a52f3070c00ef438df0680975ce"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConvertController.php" hash="c2f92c4ed528e0221fe0a1299bb0d50f"/></dir></dir><dir name="etc"><file name="config.xml" hash="9b38c777d778da7a2328f2a332034378"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Stuttme_PriceConvert.xml" hash="9b4becdd355ad557be7e0e04273aa40f"/></dir></dir></target><target name="magelocale"><dir><dir name="de_DE"><file name="Stuttme_PriceConvert.csv" hash="15e146c1014ec7ea74968b7a63a9a21a"/></dir></dir></target><target name="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="priceconvert.xml" hash="fd0f680d9f6becdc8ce3ba877365e0ef"/></dir><dir><dir name="template"><dir name="priceconvert"><file name="convert.phtml" hash="3bdd95a851ee39cee41766b462a59565"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
17
+ <compatible/>
18
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
19
+ </package>