0

I really like the magento structure but finding things is very hard ;)

My problem is that I have a custom attribute. By calling ‘create new product’ this field should be prefilled with an automatic value like the entity-id. This should only happen within the create new function.

I’m absolutely not capable of finding the corresponding code, where the initial values are set, can anyone give me a hint? (a script must run, not a default value :))

Thanks a lot and grettings, Matthias

matttrakker
  • 204
  • 3
  • 15

2 Answers2

1

You can find the information needed to find the corresponding code in this post: Finding Correct Templates and Blocks in Magento

Simply change the default attribute of the field to what you need it to be.

Community
  • 1
  • 1
Sturm
  • 4,105
  • 3
  • 24
  • 39
  • This is a missunderstanding, I want that field in the backend and by creating a new product this should be prefilled - this field will be used for exports and not available within the frontend ... – matttrakker Jun 29 '12 at 07:01
  • That link shows you how to enable template paths for the adminhtml as well. You still edit the template the same way you do the frontend. – Sturm Jun 29 '12 at 07:07
  • Your tip was not bad, especially for a general overview of the templates ... Thanks a lot! – matttrakker Jul 01 '12 at 10:53
0

The answer to my problem is overwritting the Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes block.

Within this block, you can use a simple if condiition. the following line has to be replaced by the if:

$values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();

new solution:

if($attribute->getAttributeCode() == 'my_attribute_code') {
    $values[$attribute->getAttributeCode()] = SET_THE_OWN_VALUE;
} else {
    $values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
}

That's all :)

Hope this helps some one else, too !!!

matttrakker
  • 204
  • 3
  • 15