Motech_DefaultProductStatus - Version 1.0.0

Version Notes

Allows you to set the default new product status.

Download this release

Release Info

Developer Justin Saad
Extension Motech_DefaultProductStatus
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Motech/DefaultProductStatus/Block/Settings.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Motech_DefaultAttributeSet_Block_Settings extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Settings
4
+ {
5
+ protected function _prepareLayout()
6
+ {
7
+ $this->setChild('continue_button',
8
+ $this->getLayout()->createBlock('adminhtml/widget_button')
9
+ ->setData(array(
10
+ 'label' => Mage::helper('catalog')->__('Continue'),
11
+ 'onclick' => "setSettings('".$this->getContinueUrl()."','attribute_set_id','product_type')",
12
+ 'class' => 'save'
13
+ ))
14
+ );
15
+ return parent::_prepareLayout();
16
+ }
17
+
18
+ protected function _prepareForm()
19
+ {
20
+ $form = new Varien_Data_Form();
21
+ $fieldset = $form->addFieldset('settings', array('legend'=>Mage::helper('catalog')->__('Create Product Settings')));
22
+
23
+ $entityType = Mage::registry('product')->getResource()->getEntityType();
24
+ $defaultattributeset = Mage::getStoreConfig('attributes/defaultattributeset/defaultattributeset');
25
+
26
+ $fieldset->addField('attribute_set_id', 'select', array(
27
+ 'label' => Mage::helper('catalog')->__('Attribute Set'),
28
+ 'title' => Mage::helper('catalog')->__('Attribute Set'),
29
+ 'name' => 'set',
30
+ 'value' => $defaultattributeset,
31
+ 'values'=> Mage::getResourceModel('eav/entity_attribute_set_collection')
32
+ ->setEntityTypeFilter($entityType->getId())
33
+ ->load()
34
+ ->toOptionArray()
35
+ ));
36
+
37
+
38
+ $fieldset->addField('product_type', 'select', array(
39
+ 'label' => Mage::helper('catalog')->__('Product Type'),
40
+ 'title' => Mage::helper('catalog')->__('Product Type'),
41
+ 'name' => 'type',
42
+ 'value' => '',
43
+ 'values'=> Mage::getModel('catalog/product_type')->getOptionArray()
44
+ ));
45
+
46
+ $fieldset->addField('continue_button', 'note', array(
47
+ 'text' => $this->getChildHtml('continue_button'),
48
+ ));
49
+
50
+ $this->setForm($form);
51
+ }
52
+
53
+ public function getContinueUrl()
54
+ {
55
+ return $this->getUrl('*/*/new', array(
56
+ '_current' => true,
57
+ 'set' => '{{attribute_set}}',
58
+ 'type' => '{{type}}'
59
+ ));
60
+ }
61
+ }
app/code/community/Motech/DefaultProductStatus/Model/ProductStatusOptions.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Motech_DefaultProductStatus_Model_ProductStatusOptions
4
+ {
5
+ /**
6
+ * Retrieve all options
7
+ */
8
+ public function toOptionArray()
9
+ {
10
+
11
+ return array (
12
+ array("label" => "No Default", "value" => '0'),
13
+ array("label" => "Enabled", "value" => 1),
14
+ array("label" => "Disabled", "value" => 2),
15
+ );
16
+ }
17
+ }
18
+
19
+
20
+ ?>
app/code/community/Motech/DefaultProductStatus/Model/Saveconfig.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Motech_DefaultProductStatus_Model_Saveconfig extends Mage_Core_Model_Config_Data
4
+ {
5
+ public function _afterSave()
6
+ {
7
+ Mage::log($this->getValue());
8
+
9
+ /**
10
+ * Get the resource model
11
+ */
12
+ $resource = Mage::getSingleton('core/resource');
13
+
14
+ /**
15
+ * Retrieve the write connection
16
+ */
17
+ $writeConnection = $resource->getConnection('core_write');
18
+
19
+ /**
20
+ * Retrieve our table name
21
+ */
22
+ $table = $resource->getTableName('eav_attribute');
23
+
24
+ $query = "UPDATE ".$table." SET default_value = ".$this->getValue()." WHERE attribute_code = 'status' AND frontend_input = 'select'";
25
+
26
+ /**
27
+ * Execute the query
28
+ */
29
+ $writeConnection->query($query);
30
+
31
+ return parent::_afterSave();
32
+ }
33
+
34
+ }
35
+
36
+ ?>
app/code/community/Motech/DefaultProductStatus/etc/config.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+
4
+ <modules>
5
+ <Treestone_DefaultProductStatus>
6
+ <version>1.0.0</version>
7
+ </Treestone_DefaultProductStatus>
8
+ </modules>
9
+
10
+ <adminhtml>
11
+ <acl>
12
+ <resources>
13
+ <all>
14
+ <title>Allow Everything</title>
15
+ </all>
16
+ <admin>
17
+ <children>
18
+ <system>
19
+ <children>
20
+ <config>
21
+ <children>
22
+ <motech_catalog>
23
+ <title>Motech Catalog</title>
24
+ </motech_catalog>
25
+ </children>
26
+ </config>
27
+ </children>
28
+ </system>
29
+ </children>
30
+ </admin>
31
+ </resources>
32
+ </acl>
33
+ </adminhtml>
34
+
35
+ <global>
36
+ <models>
37
+ <defaultproductstatus>
38
+ <class>Motech_DefaultProductStatus_Model</class>
39
+ </defaultproductstatus>
40
+ </models>
41
+ </global>
42
+
43
+
44
+ </config>
app/code/community/Motech/DefaultProductStatus/etc/system.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <motech translate="label">
5
+ <label>Motech Extensions</label>
6
+ <sort_order>100</sort_order>
7
+ </motech>
8
+ </tabs>
9
+ <sections>
10
+ <motech_catalog translate="label">
11
+ <label>Catalog</label>
12
+ <tab>motech</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>250</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+
19
+ <groups>
20
+ <defaultproductstatus translate="label">
21
+ <label>Default Product Status</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>1</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+
28
+ <fields>
29
+ <defaultproductstatus translate="label">
30
+ <label>Default Product Status</label>
31
+ <frontend_type>select</frontend_type>
32
+ <source_model>Motech_DefaultProductStatus_Model_ProductStatusOptions</source_model>
33
+ <backend_model>defaultproductstatus/saveconfig</backend_model>
34
+ <sort_order>1</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ <comment>Defines the default product status to use when adding a new product</comment>
39
+ </defaultproductstatus>
40
+ </fields>
41
+ </defaultproductstatus>
42
+ </groups>
43
+ </motech_catalog>
44
+ </sections>
45
+ </config>
app/etc/modules/Motech_DefaultProductStatus.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Motech_DefaultProductStatus>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Motech_DefaultProductStatus>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Motech_DefaultProductStatus</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Allows you to set the default new product status.</summary>
10
+ <description>Allows you to set the default new product status.</description>
11
+ <notes>Allows you to set the default new product status.</notes>
12
+ <authors><author><name>Justin Saad</name><user>Motech</user><email>support@motechnetwork.com</email></author></authors>
13
+ <date>2012-12-13</date>
14
+ <time>04:24:38</time>
15
+ <contents><target name="magecommunity"><dir name="Motech"><dir name="DefaultProductStatus"><dir name="Block"><file name="Settings.php" hash="259fe226c520785f05c0c77841f7a0ef"/></dir><dir name="Model"><file name="ProductStatusOptions.php" hash="d808918fa065c02549d0bc020699e23b"/><file name="Saveconfig.php" hash="e7dfbb6451cd517f56365c3f9efe8041"/></dir><dir name="etc"><file name="config.xml" hash="1b34bb1acfc7d0fc07ccb3a45baf8517"/><file name="system.xml" hash="dfd1776eb8322dc777810b4189647b62"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Motech_DefaultProductStatus.xml" hash="8ec2b32a6997e8878ff6634a0b6987f7"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>