Medma_Category_Attribute - Version 1.0.0

Version Notes

First Preview Release

Download this release

Release Info

Developer Medma Infomatix
Extension Medma_Category_Attribute
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/local/Medma/Attrib/etc/config.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Medma_Attrib>
5
+ <version>0.1.0</version>
6
+ </Medma_Attrib>
7
+ </modules>
8
+
9
+ <global>
10
+ <resources>
11
+ <attrib_setup>
12
+ <setup>
13
+ <module>Medma_Attrib</module>
14
+ <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
15
+ </setup>
16
+ <connection>
17
+ <use>core_setup</use>
18
+ </connection>
19
+ </attrib_setup>
20
+ <attrib_setup_write>
21
+ <connection>
22
+ <use>core_write</use>
23
+ </connection>
24
+ </attrib_setup_write>
25
+ <attrib_setup_read>
26
+ <connection>
27
+ <use>core_read</use>
28
+ </connection>
29
+ </attrib_setup_read>
30
+ </resources>
31
+ </global>
32
+ </config>
app/code/local/Medma/Attrib/etc/config.xml~ ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Medma_Attrib>
5
+ <version>0.1.0</version>
6
+ </Medma_Attrib>
7
+ </modules>
8
+
9
+ <global>
10
+ <resources>
11
+ <attrib_setup>
12
+ <setup>
13
+ <module>Medma_Attrib</module>
14
+ <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
15
+ </setup>
16
+ <connection>
17
+ <use>core_setup</use>
18
+ </connection>
19
+ </attrib_setup>
20
+ <attrib_setup_write>
21
+ <connection>
22
+ <use>core_write</use>
23
+ </connection>
24
+ </attrib_setup_write>
25
+ <attrib_setup_read>
26
+ <connection>
27
+ <use>core_read</use>
28
+ </connection>
29
+ </attrib_setup_read>
30
+ </resources>
31
+ </global>
32
+ </config>
app/code/local/Medma/Attrib/sql/attrib_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+ $entityTypeId = $installer->getEntityTypeId('catalog_category');
6
+ $attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
7
+ $attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
8
+
9
+ $installer->addAttribute('catalog_category', 'start_date', array(
10
+ 'type' => 'datetime',
11
+ 'label' => 'Start Date',
12
+ 'input' => 'date',
13
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
14
+ 'visible' => true,
15
+ 'required' => false,
16
+ 'user_defined' => false,
17
+ 'default' => 0
18
+ ));
19
+
20
+ $installer->addAttributeToGroup(
21
+ $entityTypeId,
22
+ $attributeSetId,
23
+ $attributeGroupId,
24
+ 'start_date',
25
+ '11'
26
+
27
+ //last Magento's attribute position in General tab is 10
28
+ );
29
+
30
+ $attributeId = $installer->getAttributeId($entityTypeId, 'start_date');
31
+
32
+ $installer->run("
33
+ INSERT INTO `{$installer->getTable('catalog_category_entity_int')}`
34
+ (`entity_type_id`, `attribute_id`, `entity_id`, `value`)
35
+ SELECT '{$entityTypeId}', '{$attributeId}', `entity_id`, '1'
36
+ FROM `{$installer->getTable('catalog_category_entity')}`;
37
+ ");
38
+
39
+ /***********************add second attribute*******************/
40
+ $installer->addAttribute('catalog_category', 'display_date', array(
41
+ 'type' => 'datetime',
42
+ 'label' => 'Expiry Date',
43
+ 'input' => 'date',
44
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
45
+ 'visible' => true,
46
+ 'required' => false,
47
+ 'user_defined' => false,
48
+ 'default' => 0
49
+ ));
50
+
51
+ $installer->addAttributeToGroup(
52
+ $entityTypeId,
53
+ $attributeSetId,
54
+ $attributeGroupId,
55
+ 'display_date',
56
+ '12' //last Magento's attribute position in General tab is 10
57
+ );
58
+
59
+ $attributeId = $installer->getAttributeId($entityTypeId, 'display_date');
60
+
61
+ $installer->run("
62
+ INSERT INTO `{$installer->getTable('catalog_category_entity_int')}`
63
+ (`entity_type_id`, `attribute_id`, `entity_id`, `value`)
64
+ SELECT '{$entityTypeId}', '{$attributeId}', `entity_id`, '1'
65
+ FROM `{$installer->getTable('catalog_category_entity')}`;
66
+ ");
67
+ /***********************add second attribute********************/
68
+ //this will set data of your custom attribute for root category
69
+ Mage::getModel('catalog/category')
70
+ ->load(1)
71
+ ->setImportedCatId(0)
72
+ ->setInitialSetupFlag(true)
73
+ ->save();
74
+
75
+ //this will set data of your custom attribute for default category
76
+ Mage::getModel('catalog/category')
77
+ ->load(2)
78
+ ->setImportedCatId(0)
79
+ ->setInitialSetupFlag(true)
80
+ ->save();
81
+
82
+ $installer->endSetup();
83
+ ?>
app/code/local/Medma/Attrib/sql/attrib_setup/mysql4-install-0.1.0.php~ ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+ $entityTypeId = $installer->getEntityTypeId('catalog_category');
6
+ $attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
7
+ $attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
8
+
9
+ $installer->addAttribute('catalog_category', 'new_cat_attrb', array(
10
+ 'type' => 'text',
11
+ 'label' => 'BIC Code',
12
+ 'input' => 'text',
13
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
14
+ 'visible' => true,
15
+ 'required' => false,
16
+ 'user_defined' => false,
17
+ 'default' => 0
18
+ ));
19
+
20
+ $installer->addAttributeToGroup(
21
+ $entityTypeId,
22
+ $attributeSetId,
23
+ $attributeGroupId,
24
+ 'new_cat_attrb',
25
+ '11'
26
+
27
+ //last Magento's attribute position in General tab is 10
28
+ );
29
+
30
+ $attributeId = $installer->getAttributeId($entityTypeId, 'new_cat_attrb');
31
+
32
+ $installer->run("
33
+ INSERT INTO `{$installer->getTable('catalog_category_entity_int')}`
34
+ (`entity_type_id`, `attribute_id`, `entity_id`, `value`)
35
+ SELECT '{$entityTypeId}', '{$attributeId}', `entity_id`, '1'
36
+ FROM `{$installer->getTable('catalog_category_entity')}`;
37
+ ");
38
+
39
+ //this will set data of your custom attribute for root category
40
+ Mage::getModel('catalog/category')
41
+ ->load(1)
42
+ ->setImportedCatId(0)
43
+ ->setInitialSetupFlag(true)
44
+ ->save();
45
+
46
+ //this will set data of your custom attribute for default category
47
+ Mage::getModel('catalog/category')
48
+ ->load(2)
49
+ ->setImportedCatId(0)
50
+ ->setInitialSetupFlag(true)
51
+ ->save();
52
+
53
+ $installer->endSetup();
54
+ ?>
app/etc/modules/Medma_Attrib.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Medma_Attrib>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Medma_Attrib>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Medma_Category_Attribute</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSLv3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This module mainly used to create an date type attribute in category.As we all know that we can not add attribute to category directly in magento</summary>
10
+ <description>This module mainly used to create an date type attribute in category.As we all know that we can not add attribute to category directly in magento</description>
11
+ <notes>First Preview Release</notes>
12
+ <authors><author><name>Medma Infomatix</name><user>Medma_Infomatix</user><email>gaurav@medma.in</email></author></authors>
13
+ <date>2012-10-01</date>
14
+ <time>05:53:43</time>
15
+ <contents><target name="magelocal"><dir name="Medma"><dir name="Attrib"><dir name="etc"><file name="config.xml" hash="008862d58ac3ae91021902a6ddee8c1f"/><file name="config.xml~" hash="008862d58ac3ae91021902a6ddee8c1f"/></dir><dir name="sql"><dir name="attrib_setup"><file name="mysql4-install-0.1.0.php" hash="9a820d9b0604d50d11ab4dc472f6b464"/><file name="mysql4-install-0.1.0.php~" hash="d715bfe121713d938d6a2919446bf0f8"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Medma_Attrib.xml" hash="1886a410999c73bdde9cad3b8b25d001"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>