0

I'm investigate a compatibility problem with two m1 extensions.

For this I need a simply output of any information I can get about Mage::getSingleton('checkout/cart')->getQuote().

I have tried following (single, not all together):

$cart = Mage::getSingleton('checkout/cart')->getQuote();
file_put_contents(__DIR__ . '/debug.txt', var_export($cart, 1), FILE_APPEND);   
file_put_contents(__DIR__ . '/debug.txt', print_r($cart, 1), FILE_APPEND);  
file_put_contents(__DIR__ . '/debug.txt', print_r(get_object_vars($cart), 1), FILE_APPEND);

But this leads to a crash while the execution (From the checkout submit (after clicking order), I fall back to the cart page). This is strange, because I use Information out of $cart, at the same place. Examp: $checkoutCartQuote->getAllItems(); gives me the articles. Just 1 line above the file_put_contents. So why does it just crash when I try var_export/print_r it?

But more important: How do I now get an Output like var_dump or print_r on this object? I need to see any properties with any values.

As I work on a shop of a client, I only have limited FTP access and no access to apache log. The exception Log of M1 didn't got new lines since I started working today.

  • The Crash may isn't caused by file_put_contents, because I removed the line and it still crashes. But If I do an file_put_contents(DIR . '/debug.txt', 'foo 123' FILE_APPEND); at the same line, foo 123 appears in the debug.txt. While the other command from my question, doesn't generate something in debug.txt. – FuFu Jul 19 '18 at 13:13
1

It's likely you're actually hitting a memory limit in PHP when trying to parse the entire quote object. You could:

  • Use a debugger, like xdebug, and inspect the data through that.

  • append ->getData() to the end of getQuote() to get only the data fields, not the entire object.

  • Increase the PHP memory limit, by using ini_set('memory_limit', '-1'); at the top of the script (this should be fine for debugging, but don't commit this to production)

Personally, I'd go for the first one if you have the time.

  • Ty, the ->getData() worked for me. xdebug would be better, but I don't have this kind of access to the host. – FuFu Jul 20 '18 at 10:05
1

Did you try?

Mage::getSingleton('checkout/cart')->getQuote()->getData();

I think the full quote object is too big to print.

  • Ty, this answer worked for me. – FuFu Jul 20 '18 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.