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 +30 -28
- app/code/community/Flagbit/ChangeAttributeSet/controllers/IndexController.php +29 -29
- app/code/community/Flagbit/ChangeAttributeSet/etc/config.xml +17 -30
- app/etc/modules/Flagbit_ChangeAttributeSet.xml +2 -1
- package.xml +7 -9
app/code/community/Flagbit/ChangeAttributeSet/Block/ProductGrid.php
CHANGED
@@ -15,50 +15,52 @@
|
|
15 |
/**
|
16 |
* ChangeAttributeSet ProductGrid Block
|
17 |
*
|
18 |
-
* @version $Id: ProductGrid.php
|
19 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
|
20 |
*/
|
21 |
-
class Flagbit_ChangeAttributeSet_Block_ProductGrid
|
22 |
-
|
23 |
-
|
24 |
/**
|
25 |
-
* Class
|
26 |
-
*
|
|
|
27 |
*/
|
28 |
public function __construct() {
|
29 |
parent::__construct ();
|
30 |
}
|
31 |
|
32 |
-
|
33 |
/**
|
34 |
-
*
|
35 |
*
|
36 |
-
* @return
|
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 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
22 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
|
23 |
*/
|
24 |
-
class Flagbit_ChangeAttributeSet_IndexController
|
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 |
-
|
41 |
-
|
42 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
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[#^/
|
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 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
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.
|
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>
|
16 |
-
<time>
|
17 |
-
<contents><target name="
|
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>
|