I need to turn on the Manage Stock option

I need to turn on the Manage Stock option

July 26, 2026 · Illustrated author avatarBy Stefan Bogdanescu
I need to turn on the Manage Stock option

Updating Magento Stock Management: A Comprehensive Guide

As a senior developer working extensively with e-commerce platforms like Magento, I often encounter situations where clients need to manage stock levels for their products efficiently. In this post, we’ll guide you through the process of enabling stock management and updating relevant fields using PHP and MySQL queries.

Understanding Magento’s Stock Management

Before diving into the technical details, let’s first understand the stock management system in Magento. This feature allows you to track inventory levels accurately, set minimum quantities, and receive notifications when stocks run low.

The stock management options you mentioned - Manage Stock, Qty for Item’s Status to Become Out of Stock, Minimum Qty Allowed in Shopping Cart, and Notify for Quantity Below - are all stored within the core Magento database tables. Let’s identify them one by one.

Identifying Relevant Tables and Fields

You’re on the right track with catalog_product_entity_int. This table stores most of the product-related integer data, including stock management settings. Here are the relevant fields:

  • entity_id: The unique identifier for each product.
  • attribute_id: References the specific stock management attribute we need to update (e.g., 73 for ‘Manage Stock’).
  • value: Stores the integer value representing the desired stock management option.

Enabling Stock Management

To enable stock management for a product, you’ll want to set the value field in the catalog_product_entity_int table. The possible values are:

  • 0: Manage Stock is disabled
  • 1: Manage Stock is enabled with Qty as 1 (default value)
  • 2: Use config settings

For thousands of products, you can use a PHP script to update these values efficiently.

Updating Stock Management Options Using PHP and MySQLi

Let’s write a simple PHP script using the MySQLi extension to perform this update. Make sure you have an active database connection before proceeding.

<?php
// Assuming $connection is your established MySQLi connection
$productIds = [1, 2, 3, ...]; // Replace with actual product IDs

foreach ($productIds as $productId) {
    $manageStock = 1; // Enable stock management (value 1)
    $minimumQty = 5; // Set minimum quantity allowed in cart
    $qtyForOutOfStock = 20; // Set quantity for item's status to become out of stock
    $notifyQuantityBelow = 10; // Set notify for quantity below

    // Update Manage Stock
    $stmt_manage_stock = $connection->prepare("UPDATE catalog_product_entity_int SET value = ? WHERE entity_id = ? AND attribute_id = 73");
    $stmt_manage_stock->bind_param("ii", $manageStock, $productId);
    $stmt_manage_stock->execute();

    // Update Minimum Qty Allowed in Shopping Cart
    $stmt_minimum_qty = $connection->prepare("UPDATE catalog_product_entity_int SET value = ? WHERE entity_id = ? AND attribute_id = 74");
    $stmt_minimum_qty->bind_param("ii", $minimumQty, $productId);
    $stmt_minimum_qty->execute();

    // Update Qty for Item's Status to Become Out of Stock
    $stmt_qty_for_out_of_stock = $connection->prepare("UPDATE catalog_product_entity_int SET value = ? WHERE entity_id = ? AND attribute_id = 75");
    $stmt_qty_for_out_of_stock->bind_param("ii", $qtyForOutOfStock, $productId);
    $stmt_qty_for_out_of_stock->execute();

    // Update Notify for Quantity Below
    $stmt_notify_quantity_below = $connection->prepare("UPDATE catalog_product_entity_int SET value = ? WHERE entity_id = ? AND attribute_id = 76");
    $stmt_notify_quantity_below->bind_param("ii", $notifyQuantityBelow, $productId);
    $stmt_notify_quantity_below->execute();
}

echo "Stock management options updated successfully.";
?>

Best Practices and Performance Optimization

When working with large datasets, consider the following best practices:

  1. Batch Processing: Process products in batches to minimize memory usage and improve performance.
  2. Indexing: Ensure that the necessary indexes are present on the catalog_product_entity_int table for efficient querying.
  3. Error Handling: Implement proper error handling and logging to monitor the script’s progress.

Conclusion

Enabling stock management and updating relevant fields in Magento requires a solid understanding of the platform’s database schema. By following this guide, you should now be able to efficiently update stock management options using PHP and MySQLi for thousands of products.

Remember that modifying core Magento tables directly can potentially lead to data inconsistencies or conflicts if not done carefully. Always backup your data before proceeding with any significant changes.

At Laravel Company, we specialize in helping businesses optimize their e-commerce platforms, including Magento stock management configurations tailored to specific business needs. If you require further assistance or custom solutions for your Magento installation, feel free to reach out to our team of experienced developers.

Checkout Catalog Database Configuration

Our network