Flagbit_ChangeAttributeSet - Version 1.0.0

Version Notes

Initial Release. Already tested in production context.

Download this release

Release Info

Developer Magento Core Team
Extension Flagbit_ChangeAttributeSet
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Flagbit/ChangeAttributeSet/Block/ProductGrid.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the TypoGento project *
4
+ * *
5
+ * TypoGento is free software; you can redistribute it and/or modify it *
6
+ * under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * */
14
+
15
+ /**
16
+ * ChangeAttributeSet ProductGrid Block
17
+ *
18
+ * @version $Id: ProductGrid.php 3 2008-12-10 12:56:53Z weller $
19
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
20
+ */
21
+ class Flagbit_ChangeAttributeSet_Block_ProductGrid extends Mage_Adminhtml_Block_Catalog_Product_Grid {
22
+
23
+
24
+ /**
25
+ * Class Constructor
26
+ * call the parent Constructor
27
+ */
28
+ public function __construct() {
29
+ parent::__construct ();
30
+ }
31
+
32
+
33
+ /**
34
+ * prepares Massaction
35
+ *
36
+ * @return object self
37
+ */
38
+ protected function _prepareMassaction() {
39
+
40
+ parent::_prepareMassaction();
41
+ $statuses = Mage::getSingleton('catalog/product_status')->getOptionArray();
42
+
43
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
44
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
45
+ ->load()
46
+ ->toOptionHash();
47
+
48
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
49
+ $this->getMassactionBlock()->addItem('attribute_set', array(
50
+ 'label'=> Mage::helper('catalog')->__('Change attribute set'),
51
+ 'url' => $this->getUrl('*/*/changeattributeset', array('_current'=>true)),
52
+ 'additional' => array(
53
+ 'visibility' => array(
54
+ 'name' => 'attribute_set',
55
+ 'type' => 'select',
56
+ 'class' => 'required-entry',
57
+ 'label' => Mage::helper('catalog')->__('Attribute Set'),
58
+ 'values' => $sets
59
+ )
60
+ )
61
+ ));
62
+ return $this;
63
+ }
64
+ }
app/code/community/Flagbit/ChangeAttributeSet/controllers/IndexController.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the TypoGento project *
4
+ * *
5
+ * TypoGento is free software; you can redistribute it and/or modify it *
6
+ * under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * */
14
+
15
+
16
+ require_once 'app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php';
17
+
18
+ /**
19
+ * ChangeAttributeSet Index Controller
20
+ *
21
+ * @version $Id: IndexController.php 3 2008-12-10 12:56:53Z weller $
22
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
23
+ */
24
+ class Flagbit_ChangeAttributeSet_IndexController extends Mage_Adminhtml_Catalog_ProductController {
25
+
26
+ /**
27
+ * Class Constructor
28
+ * call the parent Constructor
29
+ */
30
+ public function __constuct(){
31
+ parent::__construct();
32
+ }
33
+
34
+ /**
35
+ * Product list page
36
+ */
37
+ public function indexAction()
38
+ {
39
+
40
+ $productIds = $this->getRequest()->getParam('product');
41
+ $storeId = (int)$this->getRequest()->getParam('store', 0);
42
+ if(!is_array($productIds)) {
43
+ $this->_getSession()->addError($this->__('Please select product(s)'));
44
+ } else {
45
+ try {
46
+ foreach ($productIds as $productId) {
47
+ $product = Mage::getSingleton('catalog/product')
48
+ ->unsetData()
49
+ ->setStoreId($storeId)
50
+ ->load($productId)
51
+ ->setAttributeSetId($this->getRequest()->getParam('attribute_set'))
52
+ ->setIsMassupdate(true)
53
+ ->save();
54
+ }
55
+ Mage::dispatchEvent('catalog_product_massupdate_after', array('products'=>$productIds));
56
+ $this->_getSession()->addSuccess(
57
+ $this->__('Total of %d record(s) were successfully updated', count($productIds))
58
+ );
59
+ } catch (Exception $e) {
60
+ $this->_getSession()->addError($e->getMessage());
61
+ }
62
+ }
63
+ $this->_redirect('adminhtml/catalog_product/index/', array());
64
+ }
65
+
66
+ }
app/code/community/Flagbit/ChangeAttributeSet/etc/config.xml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Flagbit_ChangeAttributeSet>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Flagbit_ChangeAttributeSet>
8
+ </modules>
9
+ <global>
10
+
11
+ <blocks>
12
+ <adminhtml>
13
+ <rewrite>
14
+ <catalog_product_grid>Flagbit_ChangeAttributeSet_Block_ProductGrid</catalog_product_grid>
15
+ </rewrite>
16
+ </adminhtml>
17
+ </blocks>
18
+
19
+ <!-- This rewrite rule could be added to the database instead -->
20
+ <rewrite>
21
+ <!-- This is an identifier for your rewrite that should be unique -->
22
+ <flagbit_form_index>
23
+ <from><![CDATA[#^/admin/catalog_product/changeattributeset/$#]]></from>
24
+ <!--
25
+ - mymodule matches the router frontname below
26
+ - checkout_cart matches the path to your controller
27
+
28
+ Considering the router below, "/mymodule/checkout_cart/" will be
29
+ "translated" to "/MyNameSpace/MyModule/controllers/Checkout/CartController.php" (?)
30
+ -->
31
+ <to>/changeattributeset/</to>
32
+ </flagbit_form_index>
33
+ </rewrite>
34
+
35
+
36
+
37
+ </global>
38
+
39
+ <admin>
40
+ <routers>
41
+ <flagbit_changeattributeset>
42
+ <use>admin</use>
43
+ <args>
44
+ <module>Flagbit_ChangeAttributeSet</module>
45
+ <frontName>changeattributeset</frontName>
46
+ </args>
47
+ </flagbit_changeattributeset>
48
+ </routers>
49
+ </admin>
50
+
51
+ </config>
app/etc/modules/Flagbit_ChangeAttributeSet.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Flagbit_ChangeAttributeSet>
4
+ <active>true</active>
5
+ <codePool>community</codePool>
6
+ </Flagbit_ChangeAttributeSet>
7
+ </modules>
8
+ </config>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Flagbit_ChangeAttributeSet</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/gpl-license.php">GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>In Magento every product has a fixed attibute set. This module enables you to switch it.</summary>
10
+ <description>In Magento every product has a fixed attribute set that cannot be changed after the product's creation. This is in many productive contexts not an acceptable limitation.
11
+
12
+ This module overrides the standard behaviour and makes it possible to change attribute sets after the item's creation making Magento even more flexible. :)</description>
13
+ <notes>Initial Release. Already tested in production context.</notes>
14
+ <authors><author><name>Flagbit GmbH </name><user>auto-converted</user><email>magento@flagbit.de</email></author></authors>
15
+ <date>2008-12-10</date>
16
+ <time>13:15:11</time>
17
+ <contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Flagbit_ChangeAttributeSet.xml" hash="cebc1269daac2f616d11945af17f90a8"/></dir></dir></dir></target><target name="magecommunity"><dir name="Flagbit"><dir name="ChangeAttributeSet"><dir name="Block"><file name="ProductGrid.php" hash="82a3a37dfdf5e5caef3a4ab6395ea610"/></dir><dir name="controllers"><file name="IndexController.php" hash="f30b1e3ec8fd5ebebefff1b6026e4202"/></dir><dir name="etc"><file name="config.xml" hash="6a4d3fdaf5d22eef9265b545c4f5cd8f"/></dir></dir></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies/>
20
+ </package>