Magento: Custom attributes option's new value field

Jared

I want to add a custom field in Attribute option in Manage Attribute Options menu in admin. Like value column beside the position column in admin. I have attached an image.

What I have done ... (Magento 1.8)

  1. created a new field in eav_attribute_option table named value after sort_order filed.

  2. changed magento\app\design\adminhtml\default\default\template\eav\attribute\options.phtml this file to show the Value column beside the Position column.

  3. changed getOptionValues() method in this file magento\app\code\core\Mage\Eav\Block\Adminhtml\Attribute\Edit\Options\Abstract.php to get data for my custom value column from database and show in admin side. It shows the default value of db in admin form.

    But when I want to save from admin panel the data doesn’t save in db.

I've been trying to find the model or controller that actually handles writing into the database to make sure my new field saves too.

Any help would be appreciated.

(I'd post an image to make you understand, but I can't since I need 10 points to be able to do it.)

Jared

Got it!

Update: Mage/Eav/Model/Resource/Entity/Attribute.php

in function: _saveOption(Mage_Core_Model_Abstract $object)

change:

$sortOrder = !empty($option[’order’][$optionId]) ? $option[’order’][$optionId] : 0; 
if (!$intOptionId) { 
$data = array( 
‘attribute_id’ => $object->getId(), 
‘sort_order’ => $sortOrder, 
); 
$adapter->insert($optionTable, $data); 
$intOptionId = $adapter->lastInsertId($optionTable); 
} else { 
$data = array(’sort_order’ => $sortOrder); 
$where = array(’option_id =?’ => $intOptionId); 
$adapter->update($optionTable, $data, $where); 
}

for this:

$sortOrder = !empty($option[’order’][$optionId]) ? $option[’order’][$optionId] : 0; 
$yourAttribute = (isset($option[’your_attr_field’]) && !empty($option[’your_attr_field’][$optionId])) ? $option[’your_attr_field’][$optionId] : ‘’; 
if (!$intOptionId) { 
$data = array( 
‘attribute_id’ => $object->getId(), 
‘sort_order’ => $sortOrder, 
‘your_attr_field’ => $yourAttribute 
); 
$adapter->insert($optionTable, $data); 
$intOptionId = $adapter->lastInsertId($optionTable); 
} else { 
$data = array(’sort_order’ => $sortOrder, ‘your_attr_field’ => $yourAttribute); 
$where = array(’option_id =?’ => $intOptionId); 
$adapter->update($optionTable, $data, $where); 
}

I could use some help in making all this changes 'the Magento way'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Magento Cart Get Custom Option (Text Field) Value in Model/Quote/Item.php

From Dev

Magento text field attribute's value collection

From Dev

Magento Custom Sort Option

From Dev

Magento Custom Sort Option

From Dev

How to delete product custom option value programmatically in Magento?

From Dev

Can I add custom attributes to an option value in select(drop down)

From Dev

custom attributes in magento virtual products

From Dev

Creating new options for Magento attributes

From Dev

Magento: Creating new Attributes with Options

From Dev

Create a new custom field option in redux wordpress framework

From Dev

Magento Admin Edit Form Fields - Custom Model Field(s)

From Dev

Magento trigger shipping by custom option

From Dev

Magento trigger shipping by custom option

From Dev

How to save custom option field value when create order programatically?

From Dev

How to get value in Advance custom field pro option page

From Dev

Magento new custom block module

From Dev

how to change custom option price by query in magento?

From Dev

how to change custom option price by query in magento?

From Dev

Magento custom option with radio buttons on the same row

From Dev

Magento - Remove add new address option for customers

From Dev

How to get the value of custom field checkout address in Carrier Model Magento 2

From Dev

Get a value of a custom input in magento

From Dev

Get a value of a custom input in magento

From Dev

How I can add new field into "Customizable Options" of product's edit form in magento 2?

From Dev

Set new value on attributes in a namespace

From Dev

Magento: Get record of my model by custom Field

From Dev

Exporting Custom Magento Field via Export Customers

From Dev

Magento how to get attribute value by option id?

From Dev

Magento how to get attribute value by option id?

Related Related

  1. 1

    Magento Cart Get Custom Option (Text Field) Value in Model/Quote/Item.php

  2. 2

    Magento text field attribute's value collection

  3. 3

    Magento Custom Sort Option

  4. 4

    Magento Custom Sort Option

  5. 5

    How to delete product custom option value programmatically in Magento?

  6. 6

    Can I add custom attributes to an option value in select(drop down)

  7. 7

    custom attributes in magento virtual products

  8. 8

    Creating new options for Magento attributes

  9. 9

    Magento: Creating new Attributes with Options

  10. 10

    Create a new custom field option in redux wordpress framework

  11. 11

    Magento Admin Edit Form Fields - Custom Model Field(s)

  12. 12

    Magento trigger shipping by custom option

  13. 13

    Magento trigger shipping by custom option

  14. 14

    How to save custom option field value when create order programatically?

  15. 15

    How to get value in Advance custom field pro option page

  16. 16

    Magento new custom block module

  17. 17

    how to change custom option price by query in magento?

  18. 18

    how to change custom option price by query in magento?

  19. 19

    Magento custom option with radio buttons on the same row

  20. 20

    Magento - Remove add new address option for customers

  21. 21

    How to get the value of custom field checkout address in Carrier Model Magento 2

  22. 22

    Get a value of a custom input in magento

  23. 23

    Get a value of a custom input in magento

  24. 24

    How I can add new field into "Customizable Options" of product's edit form in magento 2?

  25. 25

    Set new value on attributes in a namespace

  26. 26

    Magento: Get record of my model by custom Field

  27. 27

    Exporting Custom Magento Field via Export Customers

  28. 28

    Magento how to get attribute value by option id?

  29. 29

    Magento how to get attribute value by option id?

HotTag

Archive