Add custom product attribute

How to add custom product attribute in magento?

We have created product attribute (i) “Product Company Name” which is must be required.Note:- you can download extension from this rar_image
Add custom product attribute in magento through custom module.
Note:- Firstly disable the cache from Cache Management tab which is in System tab.
there are many steps to create the extension.
Step1:- Create Mywork_AddCustomProductAttribute.xml file in app/etc/modules/.
where Mywork is Namespace and AddCustomProductAttribute is Modulename.


<?xml version="1.0"?>
<config>
<modules>
<Mywork_AddCustomProductAttribute>
<active>true</active>
<codePool>local</codePool>
</Mywork_AddCustomProductAttribute>
</modules>
</config>

Note:- 1) If you want to active the extensions then use true otherwise false.
2) there are three code pool (a) local (b) core (c) community
when we create the own extension then we use local code pool.

Step2:- Now create the config.xml file in app/code/local/Mywork/AddCustomProductAttribute/etc/


<?xml version="1.0"?>
<config>
<modules>
<Mywork_AddCustomProductAttribute>
<version>1.0.0</version>
</Mywork_AddCustomProductAttribute>
</modules>
<global>
<helpers>
<AddCustomProductAttribute>
<class>Mywork_AddCustomProductAttribute_Helper</class>
</AddCustomProductAttribute>
</helpers>
<models>
<AddCustomProductAttribute>
<class>Mywork_AddCustomProductAttribute_Model</class>
<resourceModel>AddCustomProductAttribute_mysql4</resourceModel>
</AddCustomProductAttribute>
</models>
<resources>
<AddCustomProductAttribute_setup>
<setup>
<module>Mywork_AddCustomProductAttribute</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</AddCustomProductAttribute_setup>
<AddCustomProductAttribute_write>
<connection>
<use>core_write</use>
</connection>
</AddCustomProductAttribute_write>
<AddCustomProductAttribute_read>
<connection>
<use>core_read</use>
</connection>
</AddCustomProductAttribute_read>
</resources>
</global>
</config>

Step3:- Now create the mysql4-install-1.0.0.php file in app/code/local/Mywork/AddCustomProductAttribute/sql/AddCustomProductAttribute_setup/


<?php
$installer = $this;
$installer->startSetup();
$installer->addAttribute("catalog_product", "product_companyname", array(
"type" => "varchar",
"backend" => "",
"frontend" => "",
"label" => "Product Company Name",
"input" => "text",
"class" => "",
"source" => "",
"global" => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
"visible" => true,
"required" => true,
"user_defined" => false,
"default" => "",
"searchable" => false,
"filterable" => false,
"comparable" => false,

“visible_on_front” => false,
“unique” => false,
“note” => “”
));
$installer->endSetup();

Step4:- Now create the Data.php file in app/code/local/Mywork/AddCustomProductAttribute/Helper/


<?php
class Mywork_AddCustomProductAttribute_Helper_Data extends Mage_Core_Helper_Abstract
{
}

After extension uploaded then you can see your custom product attribute on click the product.
AddCustomProductAttribute