1

I'm using a template on my Magento 1.9.1.0 and after patch with SUPEE 6788, I'm getting the following errors in my system.log:

2016-04-26T00:50:23+00:00 DEBUG (7): Cannot send headers; headers already sent in /usr/share/nginx/html/app/code/community/Ves/Tabs/controllers/IndexController.php, line 140
2016-04-26T00:50:23+00:00 DEBUG (7): HEADERS ALREADY SENT: <pre>[0] /usr/share/nginx/html/app/code/core/Mage/Core/Controller/Response/Http.php:52
[1] /usr/share/nginx/html/lib/Zend/Controller/Response/Abstract.php:771
[2] /usr/share/nginx/html/app/code/core/Mage/Core/Controller/Response/Http.php:84
[3] /usr/share/nginx/html/app/code/core/Mage/Core/Controller/Varien/Front.php:184
[4] /usr/share/nginx/html/app/code/core/Mage/Core/Model/App.php:354
[5] /usr/share/nginx/html/app/Mage.php:684
[6] /usr/share/nginx/html/index.php:87

In IndexController.php on line 140, I have this code:

echo Mage::helper('core')->jsonEncode( $json );

I think the way as json is called is causing this errors. How can I fix this?

Thanks in advance.

Hallan
  • 77
  • 9
  • 2
    have you checked for whitespaces after the closing php tags or before the opening tag on some of the files? also check this out.. http://stackoverflow.com/questions/4670031/magento-debug-headers-already-sent-error – Severino Lorilla Jr. Apr 26 '16 at 01:22
  • @severinolorillajr I verified every file without success. – Hallan Apr 26 '16 at 01:43
  • @Hallan please be aware that since you're using a community module, you should probably approach the Ves support team for help in the first instance – scrowler Apr 26 '16 at 01:53
  • what are you trying to achieve with the above code. Do you need to send encoded data to response to somewhere ? could you please clear with me – samumaretiya Apr 26 '16 at 05:30
  • 1
    @severinolorillajr I follow instructions in the link you past with sagar umaretiya answer in the end of this page. Thank you so much. – Hallan Apr 26 '16 at 19:44

1 Answers1

2

What I understand from above question that you want to encode data and uses it somewhere in your program.

If the above is true then you can try the following solution.

$this->getResponse()->clearHeaders()->setHeader('content-type', 'application/json', true);
$this->getResponse()->setBody(json_encode($json));

Thanks

samumaretiya
  • 1,175
  • 7
  • 18