I've taken over a project from someone else and am having trouble fixing a bug on the checkout/cart page. When an item is added and you're redirected to domain.com/checkout/cart when you try to remove the item, the page seems to reload but the item is still there until you manually refresh. Sometimes have the same issue with adding an item, won't appear until you refresh the page.

I've tried debugging in app/design/frontend/rwd/<theme>/template/checkout/cart.phtml but when trying to var_dump($this->getItems()) the page hangs and eventually crashes. I'm trying to see at what point the system recognises that items have been added/removed. How else can I go about outputting the items currently in the cart?

I have the other code that is generally linked to update not working

<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<?php echo $this->getChildHtml('form_before') ?>
<form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>" method="post">
    <?php echo $this->getBlockHtml('formkey'); ?>

It seems to be able to retrieve getItems() but unable to dump the returned data.

<?php foreach($this->getItems() as $_item): ?>
    <?php echo $this->getItemHtml($_item) ?>
<?php endforeach ?>
  • Try giving unlimited memory limit by using the following ini_set('memory_limit','16M'); Let me know if works. \
    – Sundar
    Aug 25, 2015 at 4:43
  • @Ponsundar It's currently set at 256M and still hangs
    – Bankzilla
    Aug 25, 2015 at 4:46
  • In general, you cannot var_dump a collection, the data can be enormous, and it's generally not very useful for debugging purpose. The delete action happens in app\code\core\Mage\Checkout\controllers\CartController.php. Look for public function deleteAction() and add $this->_getSession()->addNotice('item count='.$this->_getCart()->getItemsCount()); before the last line $this->_redirectReferer(Mage::getUrl('*/*')); You can also add the notice at the beginning to see if the item count reduces.
    – kiatng
    Aug 25, 2015 at 5:01
  • I just noticed there is a ajaxDeleteAction for minicart. You should check what is the URL for the delete icon in your cart page. The default URL should look something like this domain.com/checkout/cart/delete/id/<some number>/uenc/<some string>. If it is not like the default, then you should fix it.
    – kiatng
    Aug 25, 2015 at 5:10
  • @kiatng will have a look at the file, the remove button seems to follow the exact format you posted
    – Bankzilla
    Aug 25, 2015 at 5:18

3 Answers 3


So after debugging every single cache possible it actually turned out to be browser caching the site, this was happening for everybody that visited the site, why I still have no idea.

I added the following in .htaccess which seems to have resolved the issue

<FilesMatch "\.(html|htm|js|css|php)>
    FileETag None
    Header unset ETag
    Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"

You never var_dump these objects. They're too long and will eat your memory. You should use Mage::log for just what you need to know.

<?php foreach($this->getItems() as $_item): ?>
    <?php Mage::log($_item->getId()); // or getName(); ?>
<?php endforeach; ?>

Also, you probably want to check some debugging tools, like xdebug


CommerceBug by Alan Storm can be very helpful in these cases: http://store.pulsestorm.net/products/commerce-bug-2.

Like Pedram wrote: Never use var_dump() to dump collections. Your system will freeze as collections generally are huge data objects. Instead, iterate over the collection and use Mage::log().

Or better, have a look at CommerceBug.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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