Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does var_dump(array) result in a 500 error in Magento?

I'm trying to see what is inside all the objects of the Magento system, but when I try to var_dump the $_links variable (containing all information needed for rendering the links in the header of every page) from inside the top links template, my server responds with a 500 error. Anyone know why?

like image 871
pancake Avatar asked Nov 30 '22 04:11

pancake


2 Answers

Dumps of Magento objects get a bit messy, even if there isn't recursion there is all the EAV and cache stuff. When you have an array you'll need to dump them individually:

foreach ($_links as $object) {
    var_dump($object->debug());
}
like image 50
clockworkgeek Avatar answered Dec 06 '22 07:12

clockworkgeek


It's likely a memory error. Magento's object can be huge, and the default var_dump implementation in PHP isn't that smart about some of the circular references.

Install xDebug is a must. With xDebug, the var_dump function gets a lot smarter, and the memory limit exhausted errors mostly go away.

like image 43
Alan Storm Avatar answered Dec 06 '22 07:12

Alan Storm