How to add customer new entity type and customer new field
I want to create a new tab name as "Preference" in customer dashboard and also admin side customer edit page.
I successfully created new tab both side(means Admin and frontend).
Can any one suggest me how to create a two new field and display field in "preference tab" for both side and how i can add, edit field value.
magento-1.7 customer
add a comment |
I want to create a new tab name as "Preference" in customer dashboard and also admin side customer edit page.
I successfully created new tab both side(means Admin and frontend).
Can any one suggest me how to create a two new field and display field in "preference tab" for both side and how i can add, edit field value.
magento-1.7 customer
add a comment |
I want to create a new tab name as "Preference" in customer dashboard and also admin side customer edit page.
I successfully created new tab both side(means Admin and frontend).
Can any one suggest me how to create a two new field and display field in "preference tab" for both side and how i can add, edit field value.
magento-1.7 customer
I want to create a new tab name as "Preference" in customer dashboard and also admin side customer edit page.
I successfully created new tab both side(means Admin and frontend).
Can any one suggest me how to create a two new field and display field in "preference tab" for both side and how i can add, edit field value.
magento-1.7 customer
magento-1.7 customer
edited 26 mins ago
Teja Bhagavan Kollepara
2,98641947
2,98641947
asked Nov 29 '13 at 6:28
krutikruti
13317
13317
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Lifted from:
- https://stackoverflow.com/questions/5961290/adding-attributes-to-customer-entity/5962237#5962237
This is the code for a basic int
attribute with text
renderer:
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$setup->addAttribute('customer', 'your_attribute_code_here', array(
'input' => 'text',
'type' => 'int',
'label' => 'Some textual description',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
));
$setup->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'your_attribute_code_here',
'999' //sort_order
);
$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'your_attribute_code_here');
$oAttribute->setData('used_in_forms', array('adminhtml_customer'));
$oAttribute->save();
$setup->endSetup();
The unusual step for adding attributes is the setData('used_in_forms')
this seems to be unique to customer attributes. Without it, the field won't get rendered, certainly not in the adminhtml anyway. You can see the valid options for this array in the customer_form_attribute
database table.
In terms of using a select
with predefined options, this is what you need:
$iAttributeId = $installer->getAttributeId($entityTypeId, 'your_attribute_code_here');
$aClasses = array('TV','DVD','Home Theatre','Air Conditioner','Stereo/Hifi','Game Console','Camcorder','VCR','Set Top Box','PVR');
$aOption = array();
$aOption['attribute_id'] = $iAttributeId;
for($iCount=0;$iCount<sizeof($aClasses);$iCount++){
$aOption['value']['option'.$iCount][0] = $aClasses[$iCount];
}
$setup->addAttributeOption($aOption);
And here is a walk-through on using a custom source for your drop-down
Hope this helps,
JD
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f11324%2fhow-to-add-customer-new-entity-type-and-customer-new-field%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Lifted from:
- https://stackoverflow.com/questions/5961290/adding-attributes-to-customer-entity/5962237#5962237
This is the code for a basic int
attribute with text
renderer:
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$setup->addAttribute('customer', 'your_attribute_code_here', array(
'input' => 'text',
'type' => 'int',
'label' => 'Some textual description',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
));
$setup->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'your_attribute_code_here',
'999' //sort_order
);
$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'your_attribute_code_here');
$oAttribute->setData('used_in_forms', array('adminhtml_customer'));
$oAttribute->save();
$setup->endSetup();
The unusual step for adding attributes is the setData('used_in_forms')
this seems to be unique to customer attributes. Without it, the field won't get rendered, certainly not in the adminhtml anyway. You can see the valid options for this array in the customer_form_attribute
database table.
In terms of using a select
with predefined options, this is what you need:
$iAttributeId = $installer->getAttributeId($entityTypeId, 'your_attribute_code_here');
$aClasses = array('TV','DVD','Home Theatre','Air Conditioner','Stereo/Hifi','Game Console','Camcorder','VCR','Set Top Box','PVR');
$aOption = array();
$aOption['attribute_id'] = $iAttributeId;
for($iCount=0;$iCount<sizeof($aClasses);$iCount++){
$aOption['value']['option'.$iCount][0] = $aClasses[$iCount];
}
$setup->addAttributeOption($aOption);
And here is a walk-through on using a custom source for your drop-down
Hope this helps,
JD
add a comment |
Lifted from:
- https://stackoverflow.com/questions/5961290/adding-attributes-to-customer-entity/5962237#5962237
This is the code for a basic int
attribute with text
renderer:
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$setup->addAttribute('customer', 'your_attribute_code_here', array(
'input' => 'text',
'type' => 'int',
'label' => 'Some textual description',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
));
$setup->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'your_attribute_code_here',
'999' //sort_order
);
$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'your_attribute_code_here');
$oAttribute->setData('used_in_forms', array('adminhtml_customer'));
$oAttribute->save();
$setup->endSetup();
The unusual step for adding attributes is the setData('used_in_forms')
this seems to be unique to customer attributes. Without it, the field won't get rendered, certainly not in the adminhtml anyway. You can see the valid options for this array in the customer_form_attribute
database table.
In terms of using a select
with predefined options, this is what you need:
$iAttributeId = $installer->getAttributeId($entityTypeId, 'your_attribute_code_here');
$aClasses = array('TV','DVD','Home Theatre','Air Conditioner','Stereo/Hifi','Game Console','Camcorder','VCR','Set Top Box','PVR');
$aOption = array();
$aOption['attribute_id'] = $iAttributeId;
for($iCount=0;$iCount<sizeof($aClasses);$iCount++){
$aOption['value']['option'.$iCount][0] = $aClasses[$iCount];
}
$setup->addAttributeOption($aOption);
And here is a walk-through on using a custom source for your drop-down
Hope this helps,
JD
add a comment |
Lifted from:
- https://stackoverflow.com/questions/5961290/adding-attributes-to-customer-entity/5962237#5962237
This is the code for a basic int
attribute with text
renderer:
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$setup->addAttribute('customer', 'your_attribute_code_here', array(
'input' => 'text',
'type' => 'int',
'label' => 'Some textual description',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
));
$setup->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'your_attribute_code_here',
'999' //sort_order
);
$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'your_attribute_code_here');
$oAttribute->setData('used_in_forms', array('adminhtml_customer'));
$oAttribute->save();
$setup->endSetup();
The unusual step for adding attributes is the setData('used_in_forms')
this seems to be unique to customer attributes. Without it, the field won't get rendered, certainly not in the adminhtml anyway. You can see the valid options for this array in the customer_form_attribute
database table.
In terms of using a select
with predefined options, this is what you need:
$iAttributeId = $installer->getAttributeId($entityTypeId, 'your_attribute_code_here');
$aClasses = array('TV','DVD','Home Theatre','Air Conditioner','Stereo/Hifi','Game Console','Camcorder','VCR','Set Top Box','PVR');
$aOption = array();
$aOption['attribute_id'] = $iAttributeId;
for($iCount=0;$iCount<sizeof($aClasses);$iCount++){
$aOption['value']['option'.$iCount][0] = $aClasses[$iCount];
}
$setup->addAttributeOption($aOption);
And here is a walk-through on using a custom source for your drop-down
Hope this helps,
JD
Lifted from:
- https://stackoverflow.com/questions/5961290/adding-attributes-to-customer-entity/5962237#5962237
This is the code for a basic int
attribute with text
renderer:
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$setup->addAttribute('customer', 'your_attribute_code_here', array(
'input' => 'text',
'type' => 'int',
'label' => 'Some textual description',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
));
$setup->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'your_attribute_code_here',
'999' //sort_order
);
$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'your_attribute_code_here');
$oAttribute->setData('used_in_forms', array('adminhtml_customer'));
$oAttribute->save();
$setup->endSetup();
The unusual step for adding attributes is the setData('used_in_forms')
this seems to be unique to customer attributes. Without it, the field won't get rendered, certainly not in the adminhtml anyway. You can see the valid options for this array in the customer_form_attribute
database table.
In terms of using a select
with predefined options, this is what you need:
$iAttributeId = $installer->getAttributeId($entityTypeId, 'your_attribute_code_here');
$aClasses = array('TV','DVD','Home Theatre','Air Conditioner','Stereo/Hifi','Game Console','Camcorder','VCR','Set Top Box','PVR');
$aOption = array();
$aOption['attribute_id'] = $iAttributeId;
for($iCount=0;$iCount<sizeof($aClasses);$iCount++){
$aOption['value']['option'.$iCount][0] = $aClasses[$iCount];
}
$setup->addAttributeOption($aOption);
And here is a walk-through on using a custom source for your drop-down
Hope this helps,
JD
edited May 23 '17 at 12:37
Community♦
1
1
answered Dec 1 '13 at 21:21
B00MERB00MER
8,20321645
8,20321645
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f11324%2fhow-to-add-customer-new-entity-type-and-customer-new-field%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown