Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding Custom attribute in forms
    primarykey
    data
    text
    <p>I am using magento V1.5. I am working on Customer EAV &amp; have tried to create another EAV module.</p> <p>I have added few attributes in customer entity. Now MY requirement is those attributes must be editable from frontend as well as backend.</p> <p>Please tell me how to add those attributes in forntend form (customer edit form). &amp; Tell me what to do in backend to have those options to be editable. I am thinking if there is a way in admin like in our Form.php we prepare form with adding elements to it. then we not need to write a code to create actual html. Magento automatically does it. SO idea is it must also load the new attributes in that was just added. (like they appear in product edit.)</p> <p><strong>Second Issue is,</strong> Can u guys tell me what should I write in my Grid.php >> prepareCollection (for other EAV module ). so that it must get all the attributes with their values ( or may be few )</p> <p>here is something that I have in my Grid.php but its not working </p> <pre><code>protected function _prepareCollection() { $collection = Mage::getModel('pincodes/eavpincodes')-&gt;getCollection(); $this-&gt;setCollection($collection); return parent::_prepareCollection(); } </code></pre> <p>&amp; this is my collection file </p> <pre><code>class Namespace_Pincodes_Model_Resource_Eav_Mysql4_Eavpincodes_Collection extends Mage_Eav_Model_Entity_Collection_Abstract { protected function _construct() { $this-&gt;_init('pincodes/eavpincodes'); } } </code></pre> <p>But its not returning anything in my grid</p> <p>&amp; here is my Attribute collection file </p> <pre><code>class Inkfruit_Pincodes_Model_Resource_Eav_Mysql4_Attribute_Collection extends Mage_Eav_Model_Mysql4_Entity_Attribute_Collection { public function _construct() { $this-&gt;_init('pincodes/resource_eav_attribute', 'eav/entity_attribute'); } protected function _initSelect() { $this-&gt;getSelect()-&gt;from(array('main_table' =&gt; $this-&gt;getResource()-&gt;getMainTable())) -&gt;where('main_table.entity_type_id=?', Mage::getModel('eav/entity')-&gt;setType('pincodes_eavpincodes')-&gt;getTypeId()) -&gt;join( array('additional_table' =&gt; $this-&gt;getTable('pincodes/eavpincodes')), 'additional_table.attribute_set_id=main_table.attribute_id' // I think this sql need to be changed but I have no idea what it'll be ); return $this; } </code></pre> <p>}</p> <p>Guys thank you so much. This forum has been specially very helpful to me</p> <p>Regards SAM</p> <p>Ok guys I have created a separate module for customers that has one mysql4_install file &amp; it goes as follows </p> <pre><code>$installer = $this; $installer-&gt;startSetup(); $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $setup-&gt;addAttribute('customer', 'profile_image', array( 'label' =&gt; 'Profile Image', 'type' =&gt; 'varchar', 'input' =&gt; 'file', 'visible' =&gt; true, 'required' =&gt; false, 'user_defined' =&gt; true, )); $setup-&gt;addAttribute('customer', 'mobile', array( 'label' =&gt; 'Mobile Number', 'type' =&gt; 'int', 'input' =&gt; 'text', 'visible' =&gt; true, 'required' =&gt; false, 'user_defined' =&gt; true, )); $installer-&gt;endSetup(); $installer-&gt;installEntities(); </code></pre> <p>But when I hit the url for this module I see no error but these attributes are not in my database. </p> <p>I also have created Entity_Setup file &amp; it goes as follows I think its incorrect but I gave it a try</p> <pre><code>&lt;?php class Namespace_Customer_Entity_Setup extends Mage_Eav_Model_Entity_Setup { public function getDefaultEntities() { return array ( 'customer' =&gt; array( 'entity_model' =&gt; 'customer/customer', 'attribute_model' =&gt; 'customer/attribute', 'table' =&gt; 'customer/entity', 'attributes' =&gt; array( 'profile_image' =&gt; array( //the EAV attribute type, NOT a mysql varchar 'type' =&gt; 'varchar', 'backend' =&gt; '', 'frontend' =&gt; '', 'label' =&gt; 'Profile Image', 'input' =&gt; 'file', 'class' =&gt; '', 'source' =&gt; '', // store scope == 0 // global scope == 1 // website scope == 2 'global' =&gt; 0, 'visible' =&gt; true, 'required' =&gt; false, 'user_defined' =&gt; true, 'default' =&gt; '', 'searchable' =&gt; true, 'filterable' =&gt; true, 'comparable' =&gt; false, 'visible_on_front' =&gt; false, 'unique' =&gt; false ), 'mobile' =&gt; array( 'type' =&gt; 'varchar', 'backend' =&gt; '', 'frontend' =&gt; '', 'label' =&gt; 'Mobile Number', 'input' =&gt; 'text', 'class' =&gt; '', 'source' =&gt; '', 'global' =&gt; 0, 'visible' =&gt; true, 'required' =&gt; true, 'user_defined' =&gt; true, 'default' =&gt; '', 'searchable' =&gt; true, 'filterable' =&gt; true, 'comparable' =&gt; false, 'visible_on_front' =&gt; false, 'unique' =&gt; false ), ), ) ); } } </code></pre> <p>But I see nothing, not any new attribute in database.</p> <p>Can u guys help here whats wrong?? Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload