Version Notes
Set which attribute set to use by default when adding new products.
Download this release
Release Info
| Developer | Justin Saad |
| Extension | Motech_DefaultAttributeSet |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/community/Motech/DefaultAttributeSet/Block/Settings.php +61 -0
- app/code/community/Motech/DefaultAttributeSet/Model/AttributeSets.php +25 -0
- app/code/community/Motech/DefaultAttributeSet/etc/config.xml +46 -0
- app/code/community/Motech/DefaultAttributeSet/etc/system.xml +44 -0
- app/etc/modules/Motech_DefaultAttributeSet.xml +9 -0
- package.xml +18 -0
app/code/community/Motech/DefaultAttributeSet/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/DefaultAttributeSet/Model/AttributeSets.php
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Motech_DefaultAttributeSet_Model_AttributeSets
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Retrieve all options
|
| 7 |
+
*/
|
| 8 |
+
public function toOptionArray()
|
| 9 |
+
{
|
| 10 |
+
$entityTypeId = Mage::getModel('eav/entity')
|
| 11 |
+
->setType('catalog_product')
|
| 12 |
+
->getTypeId();
|
| 13 |
+
|
| 14 |
+
$values = Mage::getResourceModel('eav/entity_attribute_set_collection')
|
| 15 |
+
->setEntityTypeFilter($entityTypeId)
|
| 16 |
+
->load()
|
| 17 |
+
->toOptionArray();
|
| 18 |
+
|
| 19 |
+
return $values;
|
| 20 |
+
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
?>
|
app/code/community/Motech/DefaultAttributeSet/etc/config.xml
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
|
| 4 |
+
<modules>
|
| 5 |
+
<Treestone_DefaultAttributeSet>
|
| 6 |
+
<version>1.0.0</version>
|
| 7 |
+
</Treestone_DefaultAttributeSet>
|
| 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 |
+
<attributes>
|
| 23 |
+
<title>Motech Attributes</title>
|
| 24 |
+
</attributes>
|
| 25 |
+
</children>
|
| 26 |
+
</config>
|
| 27 |
+
</children>
|
| 28 |
+
</system>
|
| 29 |
+
</children>
|
| 30 |
+
</admin>
|
| 31 |
+
</resources>
|
| 32 |
+
</acl>
|
| 33 |
+
</adminhtml>
|
| 34 |
+
|
| 35 |
+
<global>
|
| 36 |
+
<blocks>
|
| 37 |
+
<adminhtml>
|
| 38 |
+
<rewrite>
|
| 39 |
+
<catalog_product_edit_tab_settings>Motech_DefaultAttributeSet_Block_Settings</catalog_product_edit_tab_settings>
|
| 40 |
+
</rewrite>
|
| 41 |
+
</adminhtml>
|
| 42 |
+
</blocks>
|
| 43 |
+
</global>
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
</config>
|
app/code/community/Motech/DefaultAttributeSet/etc/system.xml
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
<attributes translate="label">
|
| 11 |
+
<label>Attributes</label>
|
| 12 |
+
<tab>motech</tab>
|
| 13 |
+
<frontend_type>text</frontend_type>
|
| 14 |
+
<sort_order>200</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 |
+
<defaultattributeset translate="label">
|
| 21 |
+
<label>Default Attribute Set</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 |
+
<defaultattributeset translate="label">
|
| 30 |
+
<label>Default Attribute Set</label>
|
| 31 |
+
<frontend_type>select</frontend_type>
|
| 32 |
+
<source_model>Motech_DefaultAttributeSet_Model_AttributeSets</source_model>
|
| 33 |
+
<sort_order>1</sort_order>
|
| 34 |
+
<show_in_default>1</show_in_default>
|
| 35 |
+
<show_in_website>1</show_in_website>
|
| 36 |
+
<show_in_store>1</show_in_store>
|
| 37 |
+
<comment>Defines the default attribute set to use when adding a new product</comment>
|
| 38 |
+
</defaultattributeset>
|
| 39 |
+
</fields>
|
| 40 |
+
</defaultattributeset>
|
| 41 |
+
</groups>
|
| 42 |
+
</attributes>
|
| 43 |
+
</sections>
|
| 44 |
+
</config>
|
app/etc/modules/Motech_DefaultAttributeSet.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Motech_DefaultAttributeSet>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
</Motech_DefaultAttributeSet>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Motech_DefaultAttributeSet</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>Set which attribute set to use by default when adding new products.</summary>
|
| 10 |
+
<description>Set which attribute set to use by default when adding new products.</description>
|
| 11 |
+
<notes>Set which attribute set to use by default when adding new products.</notes>
|
| 12 |
+
<authors><author><name>Justin Saad</name><user>Motech</user><email>support@motechnetwork.com</email></author></authors>
|
| 13 |
+
<date>2012-12-12</date>
|
| 14 |
+
<time>20:48:13</time>
|
| 15 |
+
<contents><target name="magecommunity"><dir name="Motech"><dir name="DefaultAttributeSet"><dir name="Block"><file name="Settings.php" hash="259fe226c520785f05c0c77841f7a0ef"/></dir><dir name="Model"><file name="AttributeSets.php" hash="5986b9d961175df87639e08fb1fbe71a"/></dir><dir name="etc"><file name="config.xml" hash="b99f6b9142439143bd20379eb85f9d9e"/><file name="system.xml" hash="3a6f68f8c479dc9dea20117acec1d5c3"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Motech_DefaultAttributeSet.xml" hash="e919cb1d9124d1642cc779cf6ea24bf2"/></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
+
</package>
|
