Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How to save data from custom tab in admin
 
office309
Jr. Member
 
Total Posts:  6
Joined:  2012-02-20
 

Thanks to the webpage on fishpig.co.uk I’ve create a custom tab on the product edit page in the Magento admin. But the one thing that is missing, is how to save the data posted from that tab. I’ve searched the internet for a working answer, but without success. Could anyone help? Thanks in advance! :D

 
Magento Community Magento Community
Magento Community
Magento Community
 
Siggi_Schmitz
Enthusiast
 
Avatar
Total Posts:  811
Joined:  2011-07-03
 

Catch the event catalog_product_prepare_save with an own observer method.
In this method ($observer as parameter), you can see the post vars with $post = $observer->getRequest()->getPost();

Then you will see the post from the fields in your own tab and then you can save it or do what you want!
Does it help you?

 
Magento Community Magento Community
Magento Community
Magento Community
 
office309
Jr. Member
 
Total Posts:  6
Joined:  2012-02-20
 

I’ve tried it on different events. Nothing worked.

This is how the function looks like inside the Observer:

<?php
// get post data
$param $this->_getRequest()->getPost'param' );
// set data
$product->setData'param'$param );
// save
$product->getResource()->save$product );
//$product->save();
return $this;
?>

I’ve checked everything, but the data doesn’t want to be saved. var_dump( $param ) gives a correct value. I’m doing something wrong. Can you tell me what?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Siggi_Schmitz
Enthusiast
 
Avatar
Total Posts:  811
Joined:  2011-07-03
 

Okay, does the attribute exist in which you want to save the param value? Do you have added it to the attribute set from the product? Or do you try to save a complete new attribute value without adding the attribute before? What exactly do you try?

 
Magento Community Magento Community
Magento Community
Magento Community
 
office309
Jr. Member
 
Total Posts:  6
Joined:  2012-02-20
 

My goal is quite easy (I thought :p). What I want on the product edit page is a new (custom) tab with some fields (posted as one). I want to save that data to a product. I can’t use the attributes because of its limitations (or I should add a new field type which seems to be more difficult to me).

 
Magento Community Magento Community
Magento Community
Magento Community
 
Siggi_Schmitz
Enthusiast
 
Avatar
Total Posts:  811
Joined:  2011-07-03
 

Okay, you have 2 options: Adding an attribute and saving the new data there or adding a new field in the table....what do you mean with “limitations” ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
office309
Jr. Member
 
Total Posts:  6
Joined:  2012-02-20
 

I ‘solved’ with an attribute. Not really what I wanted, but the customer is satisfied.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top