SOLVED I solved this issue with Jonathan Hussey help I changed this line:
$mModel->getCollection()->load($mId)->getData();
for this:
$mModel->getCollection()->addFieldToFilter('met_id',$Id)->getSelect();
Problem
I created custom module which added tab to admin product page with additional text field.
When I try save this product I get this error:
a:5:{i:0;s:140:"Cannot send headers; headers already sent in /home/nano/domains/mydomain/public_html/gw/lib/Varien/Data/Collection/Db.php, line 693";i:1;s:1630:"#0 /home/nano/domains/mydomain/public_html/gw/lib/Zend/Controller/Response/Abstract.php(148): Zend_Controller_Response_Abstract->canSendHeaders(true)...
I saw that this error created in Observer.php:
$mId = $collection['m_id'];
$mModel->getCollection()->load($mId)->getData(); <-- this line give an error
$data['met_id'] = $mId;
$data['product_id'] = $product->getId();
$data['metf1'] = $this->_getRequest()->getPost('f1');
$mModel->setData($data);
$mModel->save();
Do you have any ideas how fix this ?
EDIT content of admin template tab file:
<?php
$product = Mage::registry('current_product');
$mItem = Mage::getModel('mmodel/mmodel')->getCollection()->
addFilter('product_id',$product->getId())->getFirstItem();
echo '<div class="input-field">
<label for="f1">File</label>
<input type="text" class="input-text" name="f1" id="f1" value='.$mItem['f1'].' />
</div>';
Debug backtrace after line $mModel->getCollection()->load($mId)->getData();
from Observer.php
SELECT `main_table`.* FROM `mmodel` AS `main_table`
Debug Backtrace:
File Line Function
/home/nano/domains/mydomain/public_html/gw/app/code/local/GW/MModel/Model/Observer.php 42 printDebugBacktrace
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Core/Model/App.php 1338 saveProductTabData
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Core/Model/App.php 1317 _callObserverMethod
/home/nano/domains/mydomain/public_html/gw/app/Mage.php 468 dispatchEvent
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Core/Model/Abstract.php 466 dispatchEvent
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Catalog/Model/Product.php 548 _afterSave
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Core/Model/Abstract.php 319 _afterSave
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php 714 save
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Core/Controller/Varien/Action.php 419 saveAction
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php 250 dispatch
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Core/Controller/Varien/Front.php 176 match
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Core/Model/App.php 354 dispatch
/home/nano/domains/mydomain/public_html/gw/app/Mage.php 704 run
/home/nano/domains/mydomain/public_html/gw/index.php 87 run