Flagbit_ChangeAttributeSet - Version 1.0.2

Version Notes

In Magento every product has a fixed attibute set. This module enables you to switch it.

Download this release

Release Info

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


Code changes from version 1.0.1 to 1.0.2

app/code/community/Flagbit/ChangeAttributeSet/Block/ProductGrid.php CHANGED
@@ -15,50 +15,52 @@
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
  }
15
  /**
16
  * ChangeAttributeSet ProductGrid Block
17
  *
18
+ * @version $Id: ProductGrid.php 256 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
22
+ extends Mage_Adminhtml_Block_Catalog_Product_Grid
23
+ {
24
  /**
25
+ * Class constructor
26
+ *
27
+ * Calls the parent constructor
28
  */
29
  public function __construct() {
30
  parent::__construct ();
31
  }
32
 
 
33
  /**
34
+ * Prepares massaction
35
  *
36
+ * @return Flagbit_ChangeAttributeSet_Block_ProductGrid
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
+
50
+ $this->getMassactionBlock()->addItem('attribute_set', array(
51
+ 'label'=> Mage::helper('catalog')->__('Change attribute set'),
52
+ 'url' => $this->getUrl('*/*/changeattributeset', array('_current'=>true)),
53
+ 'additional' => array(
54
+ 'visibility' => array(
55
+ 'name' => 'attribute_set',
56
+ 'type' => 'select',
57
+ 'class' => 'required-entry',
58
+ 'label' => Mage::helper('catalog')->__('Attribute Set'),
59
+ 'values' => $sets
60
+ )
61
+ )
62
+ ));
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  return $this;
65
  }
66
  }
app/code/community/Flagbit/ChangeAttributeSet/controllers/IndexController.php CHANGED
@@ -12,17 +12,17 @@
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
@@ -36,31 +36,31 @@ class Flagbit_ChangeAttributeSet_IndexController extends Mage_Adminhtml_Catalog_
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
  }
12
  * Public License for more details. *
13
  * */
14
 
 
15
  require_once 'app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php';
16
 
17
  /**
18
  * ChangeAttributeSet Index Controller
19
  *
20
+ * @version $Id: IndexController.php 256 2008-12-10 12:56:53Z weller $
21
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
22
  */
23
+ class Flagbit_ChangeAttributeSet_IndexController
24
+ extends Mage_Adminhtml_Catalog_ProductController
25
+ {
26
  /**
27
  * Class Constructor
28
  * call the parent Constructor
36
  */
37
  public function indexAction()
38
  {
39
+ $productIds = $this->getRequest()->getParam('product');
40
+ $storeId = (int)$this->getRequest()->getParam('store', 0);
41
+ if (!is_array($productIds)) {
42
+ $this->_getSession()->addError($this->__('Please select product(s)'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
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
+ }
60
+ catch (Exception $e) {
61
+ $this->_getSession()->addException($e, $e->getMessage());
62
+ }
63
+ }
64
+ $this->_redirect('adminhtml/catalog_product/index/', array());
65
  }
 
66
  }
app/code/community/Flagbit/ChangeAttributeSet/etc/config.xml CHANGED
@@ -1,14 +1,14 @@
1
- <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
  <Flagbit_ChangeAttributeSet>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
- <version>1.0.1</version>
8
  </Flagbit_ChangeAttributeSet>
9
  </modules>
 
10
  <global>
11
-
12
  <blocks>
13
  <adminhtml>
14
  <rewrite>
@@ -17,36 +17,23 @@
17
  </adminhtml>
18
  </blocks>
19
 
20
- <!-- This rewrite rule could be added to the database instead -->
21
  <rewrite>
22
- <!-- This is an identifier for your rewrite that should be unique -->
23
  <flagbit_form_index>
24
- <from><![CDATA[#^/admin/catalog_product/changeattributeset/.*#]]></from>
25
- <!--
26
- - mymodule matches the router frontname below
27
- - checkout_cart matches the path to your controller
28
-
29
- Considering the router below, "/mymodule/checkout_cart/" will be
30
- "translated" to "/MyNameSpace/MyModule/controllers/Checkout/CartController.php" (?)
31
- -->
32
  <to>/changeattributeset/</to>
33
  </flagbit_form_index>
34
- </rewrite>
35
-
36
-
37
-
38
  </global>
39
 
40
- <admin>
41
- <routers>
42
- <flagbit_changeattributeset>
43
- <use>admin</use>
44
- <args>
45
- <module>Flagbit_ChangeAttributeSet</module>
46
- <frontName>changeattributeset</frontName>
47
- </args>
48
- </flagbit_changeattributeset>
49
- </routers>
50
- </admin>
51
-
52
- </config>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
  <config>
3
  <modules>
4
  <Flagbit_ChangeAttributeSet>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
+ <version>1.0.2</version>
8
  </Flagbit_ChangeAttributeSet>
9
  </modules>
10
+
11
  <global>
 
12
  <blocks>
13
  <adminhtml>
14
  <rewrite>
17
  </adminhtml>
18
  </blocks>
19
 
 
20
  <rewrite>
 
21
  <flagbit_form_index>
22
+ <from><![CDATA[#^/{adminhtml}/catalog_product/changeattributeset/.*#]]></from>
 
 
 
 
 
 
 
23
  <to>/changeattributeset/</to>
24
  </flagbit_form_index>
25
+ </rewrite>
 
 
 
26
  </global>
27
 
28
+ <admin>
29
+ <routers>
30
+ <flagbit_changeattributeset>
31
+ <use>admin</use>
32
+ <args>
33
+ <module>Flagbit_ChangeAttributeSet</module>
34
+ <frontName>changeattributeset</frontName>
35
+ </args>
36
+ </flagbit_changeattributeset>
37
+ </routers>
38
+ </admin>
39
+ </config>
 
app/etc/modules/Flagbit_ChangeAttributeSet.xml CHANGED
@@ -1,3 +1,4 @@
 
1
  <config>
2
  <modules>
3
  <Flagbit_ChangeAttributeSet>
@@ -5,4 +6,4 @@
5
  <codePool>community</codePool>
6
  </Flagbit_ChangeAttributeSet>
7
  </modules>
8
- </config>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
  <config>
3
  <modules>
4
  <Flagbit_ChangeAttributeSet>
6
  <codePool>community</codePool>
7
  </Flagbit_ChangeAttributeSet>
8
  </modules>
9
+ </config>
package.xml CHANGED
@@ -1,20 +1,18 @@
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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Flagbit_ChangeAttributeSet</name>
4
+ <version>1.0.2</version>
5
  <stability>stable</stability>
6
+ <license uri="http://www.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. This module overrides the standard behaviour and makes it possible to change attribute sets after the item's creation making Magento even more flexible. :) Fixed 404 Redirect Bug.</description>
11
+ <notes>In Magento every product has a fixed attibute set. This module enables you to switch it.</notes>
 
 
12
  <authors><author><name>Flagbit GmbH </name><user>auto-converted</user><email>magento@flagbit.de</email></author></authors>
13
+ <date>2010-04-27</date>
14
+ <time>16:12:02</time>
15
+ <contents><target name="magecommunity"><dir name="Flagbit"><dir name="ChangeAttributeSet"><dir name="Block"><file name="ProductGrid.php" hash="b9581a01bc3bde231998594f753a851f"/></dir><dir name="controllers"><file name="IndexController.php" hash="99f4b7267e6b0edf65d929c7b3d2604e"/></dir><dir name="etc"><file name="config.xml" hash="d7c35a320ee286667a88a298b0a97c72"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Flagbit_ChangeAttributeSet.xml" hash="90087134613f57e05ebc216a6e576d4a"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>