Magento default cart quantity 1 product not 0

Magento default cart quantity 1 product not 0

August 20, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento default cart quantity 1 product not 0

Setting the Default Cart Quantity to 1 in Magento

When configuring your Magento store, you might notice that by default, the shopping cart sets the quantity of added products to 0. While this is usually intended behavior, there are instances where you may want to change it so that when a customer adds an item to their cart, the default quantity is set to 1 instead.

Understanding the Default Behavior

By default in Magento, when a customer clicks on “Add to Cart” for a product, the system initializes a new quote (shopping cart). For each new line item added to this quote, it sets the quantity to 0. This allows customers to freely adjust the desired amount of that particular product before proceeding with their order.

Changing the Default Quantity

To change this default behavior and set the default quantity to 1, you’ll need to modify a bit of core code in Magento. Please note that making direct changes to Magento’s core files is generally not recommended by Magento itself, as it can compromise the integrity of your store during updates. However, for small customizations like this, it might be acceptable.

Here are the steps:

  1. Navigate to app/code/core/Mage/Catalog/Model/Product.php

  2. Locate the function addCustomOptions (around line 2067 in Magento CE 1.9). This function is responsible for adding a product to the cart when the “Add to Cart” button is clicked.

  3. Change this part of the code:

    $cartItem = $this->getCart()->addProduct($product, $request);
    
  4. To:

    $cartItem = $this->getCart()->addProduct($product, array('qty' => 1));
    

This modification tells the system to add a product with the quantity set to 1 when it’s added to the cart.

An Alternative Approach

If you prefer not to modify core files directly, consider using Magento’s event observer functionality. You can create an observer that listens for the checkout_cart_product_add_after event and adjusts the quantity accordingly. This approach is more modular and easier to maintain than modifying core code.

An example of how this could look in your code:

public function addToCartObserver($observer)
{
    $item = $observer->getItem();
    if ($item->getQty() == 0) {
        $item->setQty(1);
    }
}

This observer checks if the quantity is currently 0 after a product has been added to the cart, and if so, it sets the quantity to 1.

Conclusion

Changing the default quantity in the Magento shopping cart requires some careful manipulation of core code or the use of event observers. It’s essential to thoroughly test your changes before deploying them on a live site to ensure they don’t introduce any unexpected bugs or problems with your existing functionality.

Remember to backup your data and codebase before making these modifications, just in case something goes wrong during the process.

For more advanced customizations like this, consider working with an experienced Magento developer. At Laravel Company, we provide professional Magento development services tailored to meet your specific business needs. Contact us today to learn how we can help you optimize your e-commerce platform for maximum performance and user satisfaction.

Magento 1 Checkout Catalog Database

Our network