Every once in a while, we run into an issue where the checkout process either stalls or redirects back to the main checkout screen, when adding a significant amount of products to the cart. There are a whole host of issues that can cause this, but the most tedious process of debugging it, is adding all of the products to the cart in the first place. We’ve written a small script to automatically add products to your cart by simply visiting the script on the website.
The script currently grabs the first 100 products that are enabled in your Magento system. You can easily tune up/down depending how many products you actually have in inventory. Be careful running it though, if you run it more than once, then it will simply re-add the same products, so you’ll double up the amount of each that you first had.
Save this script as a PHP file and run from the root of your store in any web-browser.
ie: http://store.com/cartfiller.php
<?php require_once 'app/Mage.php'; Mage::app(); Mage::getSingleton('core/session', array('name' => 'frontend')); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); $products = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToSelect('*') ->addAttributeToFilter('status', array('eq' => 1)) //show only enabled ; $products->getSelect()->limit(100); $products->load(); // Get cart instance $cart = Mage::getSingleton('checkout/cart'); $cart->init(); //add the products to the cart foreach($products as $product) { $id=$product->getId(); $cart->addProduct($id, array('qty' => 1)); print "<BR> adding :$id to your cart"; } $cart->save(); // update session Mage::getSingleton('checkout/session')->setCartWasUpdated(true); ?>Done Filling your cart go here: <a href="/checkout/cart/"> CHECKOUT</a> |
<?php
require_once ‘app/Mage.php’;
Mage::app();
Mage::getSingleton(‘core/session’, array(‘name’ => ‘frontend’));
ini_set(‘display_errors’, 1);
ini_set(‘display_startup_errors’, 1);
error_reporting(E_ALL);
$products = Mage::getModel(‘catalog/product’)
->getCollection()
->addAttributeToSelect(‘*’)
->addAttributeToFilter(‘status’, array(‘eq’ => 1)) //show only enabled
;
$products->getSelect()->limit(100);
$products->load();
// Get cart instance
$cart = Mage::getSingleton(‘checkout/cart’);
$cart->init();
//add the products to the cart
foreach($products as $product) {
$id=$product->getId();
$cart->addProduct($id, array(‘qty’ => 1));
print “<BR> adding :$id to your cart”;
}
$cart->save();
// update session
Mage::getSingleton(‘checkout/session’)->setCartWasUpdated(true);
?>Done Filling your cart go here: <a href=”/checkout/cart/”> CHECKOUT</a>