Update_Product - Version 1.0.2

Version Notes

version 1.0.2

Download this release

Release Info

Developer Abhay
Extension Update_Product
Version 1.0.2
Comparing to
See all releases


Code changes from version 1.0.1 to 1.0.2

app/code/local/Update/Product/Block/Adminhtml/Product.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Update_Product_Block_Adminhtml_Product extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_product';
7
+ $this->_blockGroup = 'product';
8
+ $this->_headerText = Mage::helper('product')->__('Item Manager');
9
+ $this->_addButtonLabel = Mage::helper('product')->__('Add Item');
10
+ parent::__construct();
11
+ $collection=Mage::getModel('product/product')->getCollection();
12
+ if(count($collection) == 0)
13
+ {
14
+ //$this->_removeButton('add');
15
+ }
16
+ else{
17
+
18
+ $this->_removeButton('add');
19
+ }
20
+
21
+
22
+ }
23
+ }
app/code/local/Update/Product/Block/Adminhtml/Product/Edit.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Update_Product_Block_Adminhtml_Product_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'product';
11
+ $this->_controller = 'adminhtml_product';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('product')->__('Save Item'));
14
+ // $this->_updateButton('delete', 'label', Mage::helper('product')->__('Delete Item'));
15
+ $this->_removeButton('delete');
16
+ $this->_removeButton('reset');
17
+ $this->_removeButton('back');
18
+
19
+ /* $this->_addButton('saveandcontinue', array(
20
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
21
+ 'onclick' => 'saveAndContinueEdit()',
22
+ 'class' => 'save',
23
+ ), -100); */
24
+
25
+ $this->_formScripts[] = "
26
+ function toggleEditor() {
27
+ if (tinyMCE.getInstanceById('product_content') == null) {
28
+ tinyMCE.execCommand('mceAddControl', false, 'product_content');
29
+ } else {
30
+ tinyMCE.execCommand('mceRemoveControl', false, 'product_content');
31
+ }
32
+ }
33
+
34
+ function saveAndContinueEdit(){
35
+ editForm.submit($('edit_form').action+'back/edit/');
36
+ }
37
+ ";
38
+ }
39
+
40
+ public function getHeaderText()
41
+ {
42
+ if( Mage::registry('product_data') && Mage::registry('product_data')->getId() ) {
43
+ return Mage::helper('product')->__("Fill Form To Update Product Price");
44
+ } else {
45
+ return Mage::helper('product')->__('Add Item');
46
+ }
47
+ }
48
+ }
app/code/local/Update/Product/Block/Adminhtml/Product/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Update_Product_Block_Adminhtml_Product_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/update', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/local/Update/Product/Block/Adminhtml/Product/Edit/Tab/Form.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Update_Product_Block_Adminhtml_Product_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset('product_form', array('legend'=>Mage::helper('product')->__('Update ALL Product Price')));
10
+
11
+ $fieldset->addField('Pfund', 'text', array(
12
+ 'label' => Mage::helper('product')->__('Pfund'),
13
+ 'name' => 'Pfund',
14
+ ));
15
+
16
+ $fieldset->addField('Euro', 'text', array(
17
+ 'label' => Mage::helper('product')->__('Euro'),
18
+ 'name' => 'Euro',
19
+ ));
20
+
21
+ $fieldset->addField('USD', 'text', array(
22
+ 'label' => Mage::helper('product')->__('USD'),
23
+ 'name' => 'USD',
24
+ ));
25
+
26
+ if ( Mage::getSingleton('adminhtml/session')->getProductData() )
27
+ {
28
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getProductData());
29
+ Mage::getSingleton('adminhtml/session')->setProductData(null);
30
+ } elseif ( Mage::registry('product_data') ) {
31
+ $form->setValues(Mage::registry('product_data')->getData());
32
+ }
33
+ return parent::_prepareForm();
34
+ }
35
+ }
app/code/local/Update/Product/Block/Adminhtml/Product/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Update_Product_Block_Adminhtml_Product_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('product_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ // $this->setTitle(Mage::helper('product')->__('Update ALL Product Price'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('product')->__('Update ALL Product Price'),
18
+ 'title' => Mage::helper('product')->__('Update ALL Product Price'),
19
+ 'content' => $this->getLayout()->createBlock('product/adminhtml_product_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/Update/Product/Block/Adminhtml/Product/Grid.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Update_Product_Block_Adminhtml_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('productGrid');
9
+ $this->setDefaultSort('product_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('product/product')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('product_id', array(
24
+ 'header' => Mage::helper('product')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'product_id',
28
+ ));
29
+
30
+
31
+ $this->addColumn('Pfund', array(
32
+ 'header' => Mage::helper('product')->__('Pfund'),
33
+ 'align' =>'left',
34
+ 'index' => 'Pfund',
35
+ ));
36
+
37
+ $this->addColumn('Euro', array(
38
+ 'header' => Mage::helper('product')->__('Euro'),
39
+ 'align' =>'left',
40
+ 'index' => 'Euro',
41
+ ));
42
+
43
+ $this->addColumn('USD', array(
44
+ 'header' => Mage::helper('product')->__('USD'),
45
+ 'align' =>'left',
46
+ 'index' => 'USD',
47
+ ));
48
+
49
+
50
+ $this->addColumn('action',
51
+ array(
52
+ 'header' => Mage::helper('product')->__('Action'),
53
+ 'width' => '100',
54
+ 'type' => 'action',
55
+ 'getter' => 'getId',
56
+ 'actions' => array(
57
+ array(
58
+ 'caption' => Mage::helper('product')->__('Edit'),
59
+ 'url' => array('base'=> '*/*/edit'),
60
+ 'field' => 'id'
61
+ )
62
+ ),
63
+ 'filter' => false,
64
+ 'sortable' => false,
65
+ 'index' => 'stores',
66
+ 'is_system' => true,
67
+ ));
68
+
69
+ $this->addExportType('*/*/exportCsv', Mage::helper('product')->__('CSV'));
70
+ $this->addExportType('*/*/exportXml', Mage::helper('product')->__('XML'));
71
+
72
+ return parent::_prepareColumns();
73
+ }
74
+
75
+ protected function _prepareMassaction()
76
+ {
77
+ $this->setMassactionIdField('product_id');
78
+ $this->getMassactionBlock()->setFormFieldName('product');
79
+
80
+ $this->getMassactionBlock()->addItem('delete', array(
81
+ 'label' => Mage::helper('product')->__('Delete'),
82
+ 'url' => $this->getUrl('*/*/massDelete'),
83
+ 'confirm' => Mage::helper('product')->__('Are you sure?')
84
+ ));
85
+
86
+ $statuses = Mage::getSingleton('product/status')->getOptionArray();
87
+
88
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
89
+ $this->getMassactionBlock()->addItem('status', array(
90
+ 'label'=> Mage::helper('product')->__('Change status'),
91
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
92
+ 'additional' => array(
93
+ 'visibility' => array(
94
+ 'name' => 'status',
95
+ 'type' => 'select',
96
+ 'class' => 'required-entry',
97
+ 'label' => Mage::helper('product')->__('Status'),
98
+ 'values' => $statuses
99
+ )
100
+ )
101
+ ));
102
+ return $this;
103
+ }
104
+
105
+ public function getRowUrl($row)
106
+ {
107
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
108
+ }
109
+
110
+ }
app/code/local/Update/Product/Block/Product.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Update_Product_Block_Product extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getProduct()
10
+ {
11
+ if (!$this->hasData('product')) {
12
+ $this->setData('product', Mage::registry('product'));
13
+ }
14
+ return $this->getData('product');
15
+
16
+ }
17
+ }
app/code/local/Update/Product/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Update_Product_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Update/Product/Model/Mysql4/Product.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Update_Product_Model_Mysql4_Product extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the product_id refers to the key field in your database table.
8
+ $this->_init('product/product', 'product_id');
9
+ }
10
+ }
app/code/local/Update/Product/Model/Mysql4/Product/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Update_Product_Model_Mysql4_Product_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('product/product');
9
+ }
10
+ }
app/code/local/Update/Product/Model/Product.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Update_Product_Model_Product extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('product/product');
9
+ }
10
+ }
app/code/local/Update/Product/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Update_Product_Model_Status extends Varien_Object
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray()
9
+ {
10
+ return array(
11
+ self::STATUS_ENABLED => Mage::helper('product')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('product')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Update/Product/controllers/Adminhtml/ProductController.php ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Update_Product_Adminhtml_ProductController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('product/items')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
10
+
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction() {
15
+ $this->_initAction()
16
+ ->renderLayout();
17
+ }
18
+
19
+ public function editAction() {
20
+ $id = $this->getRequest()->getParam('id');
21
+ $model = Mage::getModel('product/product')->load($id);
22
+
23
+ if ($model->getId() || $id == 0) {
24
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
25
+ if (!empty($data)) {
26
+ $model->setData($data);
27
+ }
28
+
29
+ Mage::register('product_data', $model);
30
+
31
+ $this->loadLayout();
32
+ $this->_setActiveMenu('product/items');
33
+
34
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
35
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
36
+
37
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
38
+
39
+ $this->_addContent($this->getLayout()->createBlock('product/adminhtml_product_edit'))
40
+ ->_addLeft($this->getLayout()->createBlock('product/adminhtml_product_edit_tabs'));
41
+
42
+ $this->renderLayout();
43
+ } else {
44
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('product')->__('Item does not exist'));
45
+ $this->_redirect('*/*/');
46
+ }
47
+ }
48
+
49
+ public function newAction() {
50
+ $this->_forward('edit');
51
+ }
52
+
53
+ public function updateAction(){
54
+
55
+ $data = $this->getRequest()->getPost();
56
+ $model = Mage::getModel('product/product');
57
+ $model->setData($data)->setId($this->getRequest()->getParam('id'));
58
+
59
+ $model->save();
60
+
61
+ $collection = Mage::getModel('product/product')->getCollection();
62
+
63
+ foreach($collection as $row) {
64
+
65
+ if (($row['Pfund'] !='') AND ($row['Euro']!=''))
66
+ {
67
+ //echo "<b>Pfund :</b>".$row['Pfund']."<br>".
68
+ //"<b>Euro :</b>".$row['Euro']."<br>".
69
+ //"<b>Dollar :</b>".$row['USD']."<br>";
70
+ //echo "<br><br>";
71
+
72
+ //echo"<h3>Pfund</h3>";
73
+ $this->updateProducts('Pfund', $row['Pfund']);
74
+
75
+ //echo"<h3>Euro</h3>";
76
+ $this->updateProducts('Euro', $row['Euro']);
77
+
78
+ //echo"<h3>US Dollar</h3>";
79
+ $this->updateProducts('USD', $row['USD']);
80
+
81
+ //echo"<h3>Australische Dollar</h3>";
82
+ $this->updateProducts('dollar',15); //xchange rate is 1:1 but shipping cost need to be updated
83
+
84
+ //inform Admin about update
85
+ //informEmail('martin.steudter@konvis.de');
86
+ }
87
+ }
88
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('product')->__('All Product Price Was Successfully Updated'));
89
+ $this->_redirect('*/*/edit/id/1');
90
+
91
+ }
92
+
93
+ public function updateProducts($currency, $xchange_rate) {
94
+
95
+ //load product collection
96
+ $product_collection = Mage::getModel('catalog/product')->getCollection()
97
+ ->addAttributeToSelect('*')
98
+ ->addFieldToFilter(
99
+ 'currency',
100
+ array(
101
+ 'eq' => Mage::getResourceModel('catalog/product')
102
+ ->getAttribute('currency')
103
+ ->getSource()
104
+ ->getOptionId($currency)
105
+ )
106
+ );
107
+
108
+ $num = 0;
109
+ foreach($product_collection as $product) {
110
+
111
+ $num++;
112
+
113
+ //print_r($product->getData());
114
+
115
+ //echo"<b>Aktualisierte Produkte:</b><br>";
116
+
117
+ //attributes for user information
118
+ $id = $product->getResource()->getAttribute('entity_id')->getFrontend()->getValue($product);
119
+ $name = $product->getResource()->getAttribute('name')->getFrontend()->getValue($product);
120
+
121
+ //attributes for price calculation
122
+ $basis_price = $product->getResource()->getAttribute('basis_preis')->getFrontend()->getValue($product);
123
+ $shippingcost = $product->getResource()->getAttribute('versandkosten')->getFrontend()->getValue($product);
124
+ //echo $shippingcost;exit;
125
+ //calulation of new price
126
+
127
+
128
+ $new_price = $basis_price / $xchange_rate + $shippingcost;
129
+
130
+
131
+ //information for user
132
+ // $output = $num." - #".$id."|".$name." - ".$basis_price." => ".$new_price. " AUD";
133
+
134
+ /* if ($shippingcost != '')
135
+ {
136
+ $output = $output." (inkl. Versand ". round($shippingcost,2)." AUD)";
137
+ } */
138
+ // echo $output."<br>";
139
+
140
+ //updating product price
141
+ $product->setPrice($new_price)
142
+ ->save();
143
+
144
+ }
145
+
146
+
147
+ //echo "<b>Aktualisierter Produkte </b>".$num; //update Products
148
+ //echo "<br><br>";
149
+ }
150
+
151
+ public function saveAction() {
152
+ if ($data = $this->getRequest()->getPost()) {
153
+
154
+
155
+
156
+ $model = Mage::getModel('product/product');
157
+ $model->setData($data)
158
+ ->setId($this->getRequest()->getParam('id'));
159
+
160
+ try {
161
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
162
+ $model->setCreatedTime(now())
163
+ ->setUpdateTime(now());
164
+ } else {
165
+ $model->setUpdateTime(now());
166
+ }
167
+
168
+ $model->save();
169
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('product')->__('Item was successfully saved'));
170
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
171
+
172
+ if ($this->getRequest()->getParam('back')) {
173
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
174
+ return;
175
+ }
176
+ $this->_redirect('*/*/');
177
+ return;
178
+ } catch (Exception $e) {
179
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
180
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
181
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
182
+ return;
183
+ }
184
+ }
185
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('product')->__('Unable to find item to save'));
186
+ $this->_redirect('*/*/');
187
+ }
188
+
189
+ public function deleteAction() {
190
+ if( $this->getRequest()->getParam('id') > 0 ) {
191
+ try {
192
+ $model = Mage::getModel('product/product');
193
+
194
+ $model->setId($this->getRequest()->getParam('id'))
195
+ ->delete();
196
+
197
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
198
+ $this->_redirect('*/*/');
199
+ } catch (Exception $e) {
200
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
201
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
202
+ }
203
+ }
204
+ $this->_redirect('*/*/');
205
+ }
206
+
207
+ public function massDeleteAction() {
208
+ $productIds = $this->getRequest()->getParam('product');
209
+ if(!is_array($productIds)) {
210
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
211
+ } else {
212
+ try {
213
+ foreach ($productIds as $productId) {
214
+ $product = Mage::getModel('product/product')->load($productId);
215
+ $product->delete();
216
+ }
217
+ Mage::getSingleton('adminhtml/session')->addSuccess(
218
+ Mage::helper('adminhtml')->__(
219
+ 'Total of %d record(s) were successfully deleted', count($productIds)
220
+ )
221
+ );
222
+ } catch (Exception $e) {
223
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
224
+ }
225
+ }
226
+ $this->_redirect('*/*/index');
227
+ }
228
+
229
+ public function massStatusAction()
230
+ {
231
+ $productIds = $this->getRequest()->getParam('product');
232
+ if(!is_array($productIds)) {
233
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
234
+ } else {
235
+ try {
236
+ foreach ($productIds as $productId) {
237
+ $product = Mage::getSingleton('product/product')
238
+ ->load($productId)
239
+ ->setStatus($this->getRequest()->getParam('status'))
240
+ ->setIsMassupdate(true)
241
+ ->save();
242
+ }
243
+ $this->_getSession()->addSuccess(
244
+ $this->__('Total of %d record(s) were successfully updated', count($productIds))
245
+ );
246
+ } catch (Exception $e) {
247
+ $this->_getSession()->addError($e->getMessage());
248
+ }
249
+ }
250
+ $this->_redirect('*/*/index');
251
+ }
252
+
253
+ public function exportCsvAction()
254
+ {
255
+ $fileName = 'product.csv';
256
+ $content = $this->getLayout()->createBlock('product/adminhtml_product_grid')
257
+ ->getCsv();
258
+
259
+ $this->_sendUploadResponse($fileName, $content);
260
+ }
261
+
262
+ public function exportXmlAction()
263
+ {
264
+ $fileName = 'product.xml';
265
+ $content = $this->getLayout()->createBlock('product/adminhtml_product_grid')
266
+ ->getXml();
267
+
268
+ $this->_sendUploadResponse($fileName, $content);
269
+ }
270
+
271
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
272
+ {
273
+ $response = $this->getResponse();
274
+ $response->setHeader('HTTP/1.1 200 OK','');
275
+ $response->setHeader('Pragma', 'public', true);
276
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
277
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
278
+ $response->setHeader('Last-Modified', date('r'));
279
+ $response->setHeader('Accept-Ranges', 'bytes');
280
+ $response->setHeader('Content-Length', strlen($content));
281
+ $response->setHeader('Content-type', $contentType);
282
+ $response->setBody($content);
283
+ $response->sendResponse();
284
+ die;
285
+ }
286
+ }
app/code/local/Update/Product/controllers/IndexController.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Update_Product_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+
7
+ /*
8
+ * Load an object by id
9
+ * Request looking like:
10
+ * http://site.com/product?id=15
11
+ * or
12
+ * http://site.com/product/id/15
13
+ */
14
+ /*
15
+ $product_id = $this->getRequest()->getParam('id');
16
+
17
+ if($product_id != null && $product_id != '') {
18
+ $product = Mage::getModel('product/product')->load($product_id)->getData();
19
+ } else {
20
+ $product = null;
21
+ }
22
+ */
23
+
24
+ /*
25
+ * If no param we load a the last created item
26
+ */
27
+ /*
28
+ if($product == null) {
29
+ $resource = Mage::getSingleton('core/resource');
30
+ $read= $resource->getConnection('core_read');
31
+ $productTable = $resource->getTableName('product');
32
+
33
+ $select = $read->select()
34
+ ->from($productTable,array('product_id','title','content','status'))
35
+ ->where('status',1)
36
+ ->order('created_time DESC') ;
37
+
38
+ $product = $read->fetchRow($select);
39
+ }
40
+ Mage::register('product', $product);
41
+ */
42
+
43
+
44
+ $this->loadLayout();
45
+ $this->renderLayout();
46
+ }
47
+ }
app/code/local/Update/Product/etc/config.xml ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Update_Product>
5
+ <version>0.1.0</version>
6
+ </Update_Product>
7
+ </modules>
8
+ <!--<frontend>
9
+ <routers>
10
+ <product>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Update_Product</module>
14
+ <frontName>product</frontName>
15
+ </args>
16
+ </product>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <product>
21
+ <file>product.xml</file>
22
+ </product>
23
+ </updates>
24
+ </layout>
25
+ </frontend>-->
26
+ <admin>
27
+ <routers>
28
+ <product>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>Update_Product</module>
32
+ <frontName>product</frontName>
33
+ </args>
34
+ </product>
35
+ </routers>
36
+ </admin>
37
+ <adminhtml>
38
+ <menu>
39
+ <product module="product">
40
+ <title>xChange Rate Updater KonVis</title>
41
+ <sort_order>71</sort_order>
42
+ <action>product/adminhtml_product/edit/id/1</action>
43
+ <!--<children>
44
+ <items module="product">
45
+ <title>Manage Items</title>
46
+ <sort_order>0</sort_order>
47
+ <action>product/adminhtml_product</action>
48
+ </items>
49
+ </children>-->
50
+ </product>
51
+ </menu>
52
+ <acl>
53
+ <resources>
54
+ <all>
55
+ <title>Allow Everything</title>
56
+ </all>
57
+ <admin>
58
+ <children>
59
+ <Update_Product>
60
+ <title>Product Module</title>
61
+ <sort_order>10</sort_order>
62
+ </Update_Product>
63
+ </children>
64
+ </admin>
65
+ </resources>
66
+ </acl>
67
+ <layout>
68
+ <updates>
69
+ <product>
70
+ <file>product.xml</file>
71
+ </product>
72
+ </updates>
73
+ </layout>
74
+ </adminhtml>
75
+ <global>
76
+ <models>
77
+ <product>
78
+ <class>Update_Product_Model</class>
79
+ <resourceModel>product_mysql4</resourceModel>
80
+ </product>
81
+ <product_mysql4>
82
+ <class>Update_Product_Model_Mysql4</class>
83
+ <entities>
84
+ <product>
85
+ <table>product</table>
86
+ </product>
87
+ </entities>
88
+ </product_mysql4>
89
+ </models>
90
+ <resources>
91
+ <product_setup>
92
+ <setup>
93
+ <module>Update_Product</module>
94
+ </setup>
95
+ <connection>
96
+ <use>core_setup</use>
97
+ </connection>
98
+ </product_setup>
99
+ <product_write>
100
+ <connection>
101
+ <use>core_write</use>
102
+ </connection>
103
+ </product_write>
104
+ <product_read>
105
+ <connection>
106
+ <use>core_read</use>
107
+ </connection>
108
+ </product_read>
109
+ </resources>
110
+ <blocks>
111
+ <product>
112
+ <class>Update_Product_Block</class>
113
+ </product>
114
+ </blocks>
115
+ <helpers>
116
+ <product>
117
+ <class>Update_Product_Helper</class>
118
+ </product>
119
+ </helpers>
120
+ </global>
121
+ </config>
app/code/local/Update/Product/sql/product_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('product')};
10
+ CREATE TABLE {$this->getTable('product')} (
11
+ `product_id` int(11) unsigned NOT NULL auto_increment,
12
+ `Pfund` varchar(255) NOT NULL default '',
13
+ `Euro` varchar(255) NOT NULL default '',
14
+ `USD` varchar(255) NOT NULL default '',
15
+ `created_time` datetime NULL,
16
+ `update_time` datetime NULL,
17
+ PRIMARY KEY (`product_id`)
18
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
19
+
20
+ ");
21
+
22
+ $installer->endSetup();
package.xml CHANGED
@@ -1,28 +1,26 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Update_Product</name>
4
- <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Extension is use for those product who depend on their base price ,shipping cost and currency &#xD;
10
- you can change all product price by admin based on currency of product </summary>
11
- <description>you can use this extension to use this plugin for update product price&#xD;
12
- for this plugin i have create 3 custom attribute for each product&#xD;
13
- 1)basis_preis(base_price)&#xD;
14
- 2)versandkosten (shipping cost)&#xD;
15
- 3)currency(name:-pfund,euro,usd)&#xD;
16
- you can use above extension after creating this 3 attribute this plugin is only for those product which price is based on their base price and shipping cost and as well as based on currency &#xD;
17
  &#xD;
18
- for more details see screenshot or &#xD;
19
- also visit: http://abhaykhatariya.blogspot.com/&#xD;
20
- also you can contact me for more details.</description>
21
- <notes>version 1.0.1 Update Product Price</notes>
 
 
 
 
22
  <authors><author><name>Abhay</name><user>abhay5683</user><email>abhay5683@gmail.com</email></author></authors>
23
- <date>2013-12-16</date>
24
- <time>05:13:19</time>
25
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="product.xml" hash="1103efb130a413b72dda89238c5eab11"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="product.xml" hash="15c583e2eadfbbf3f8c31a5d712a62ba"/></dir><dir name="template"><dir name="product"><file name="product.phtml" hash="22d23c1938d0b9c97b24ba0f92845356"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Update_Product.xml" hash="e9ce23cd85f68e216ca1c4aae8e4493d"/></dir></target></contents>
26
  <compatible/>
27
  <dependencies><required><php><min>5.1.0</min><max>5.4.10</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.7.0.2</max></package></required></dependencies>
28
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Update_Product</name>
4
+ <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>update_product module is used to set all product price as per their shipping cost and basic price of product</summary>
10
+ <description>update_product module is used to set all product price as per their shipping cost and basic price of product&#xD;
 
 
 
 
 
 
11
  &#xD;
12
+ &#xD;
13
+ to integrated this extension use above screenshot and before integrate add two attribute name "basis_preis" and "versandkosten" in admin and assing to default attribute set&#xD;
14
+ after set this two attribute which is product basis price and shippingcost which are you can decide for each product&#xD;
15
+ and after integrated this extension you can chnage your product every when you need to change&#xD;
16
+ you can change product price as per currency Pfund,Euro,USD&#xD;
17
+ for more details visit http://abhaykhatariya.blogspot.in/&#xD;
18
+ contact me for more details </description>
19
+ <notes>version 1.0.2</notes>
20
  <authors><author><name>Abhay</name><user>abhay5683</user><email>abhay5683@gmail.com</email></author></authors>
21
+ <date>2013-12-17</date>
22
+ <time>06:57:23</time>
23
+ <contents><target name="magelocal"><dir name="Update"><dir name="Product"><dir name="Block"><dir name="Adminhtml"><dir name="Product"><dir name="Edit"><file name="Form.php" hash="363b339e473ff0e3bdd894ebc7c666f7"/><dir name="Tab"><file name="Form.php" hash="2cd7ad62e32e7b7b673add9f53799e5c"/></dir><file name="Tabs.php" hash="fbb15757ec1d0bf9649134ebdc402463"/></dir><file name="Edit.php" hash="6782dc2d1a1d780ba1d6df52f1f356a0"/><file name="Grid.php" hash="451c81a3592f7fa10129bc028f07dcee"/></dir><file name="Product.php" hash="93847b81c4bee961d7d7629b4bb5ecc9"/></dir><file name="Product.php" hash="76ef1ac9c4ac4affcfcfb664f5fc057e"/></dir><dir name="Helper"><file name="Data.php" hash="0bfc0d566e5717099ef4ddad157c851d"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Product"><file name="Collection.php" hash="a924eead62f3723798c61cfcdec40eeb"/></dir><file name="Product.php" hash="299bb7c0663f4371f4a5aced9866f3ea"/></dir><file name="Product.php" hash="48f765e6af22f9cfb52cdd570a28ae89"/><file name="Status.php" hash="a3ba027bf88cfd7e29505a4fec1c3912"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ProductController.php" hash="960998d9e354ae788d10628531d6bb96"/></dir><file name="IndexController.php" hash="87d42fa799e55f1242e83fe3184f15c7"/></dir><dir name="etc"><file name="config.xml" hash="e7de3d0e61c9db4d4300067978d82290"/></dir><dir name="sql"><dir name="product_setup"><file name="mysql4-install-0.1.0.php" hash="f4ee10c09b5e785dfe0b6308cf938029"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Update_Product.xml" hash="e9ce23cd85f68e216ca1c4aae8e4493d"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="product.xml" hash="1103efb130a413b72dda89238c5eab11"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="product.xml" hash="15c583e2eadfbbf3f8c31a5d712a62ba"/></dir><dir name="template"><dir name="product"><file name="product.phtml" hash="22d23c1938d0b9c97b24ba0f92845356"/></dir></dir></dir></dir></dir></target></contents>
24
  <compatible/>
25
  <dependencies><required><php><min>5.1.0</min><max>5.4.10</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.7.0.2</max></package></required></dependencies>
26
  </package>