How to programmatically disable product for all store-view in Magento?

How to programmatically disable product for all store-view in Magento?

July 3, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to programmatically disable product for all store-view in Magento?

Disabling Products Programmatically Across All Store Views in Magento

If you’re looking to disable products programmatically across all store views in your Magento installation, you’ve come to the right place. In this post, we’ll guide you through the process and provide a working solution that ensures every store view is affected.

The Challenge: Disabling Products Across Multiple Store Views

Magento’s multi-store functionality allows you to create separate stores for different regions or languages. However, when it comes to disabling products, Magento doesn’t provide an out-of-the-box way to do this across all store views simultaneously.

The issue lies in the fact that product visibility is handled independently for each store view. So, even if a product is disabled in one view, it might still be visible in others.

The Solution: A Multi-Store Product Disabling Script

To disable products across all store views programmatically, you’ll need to create a custom script that loops through every store and updates the product status accordingly.

Before we dive into the code, let’s make sure your environment is set up correctly:

  1. Enable debugging mode in Magento for better error handling.
  2. Make sure you have access to write permissions on the catalog_product_entity table in your database.
  3. Ensure the product ID you want to disable is correct.

Step-by-Step Guide: Disabling Products via PHP

Here’s a step-by-step guide to creating a script that disables products across all store views:

  1. Open your SSH terminal and navigate to your Magento root directory.

  2. Create a new file named disable_product.php in the root folder (or any suitable directory).

  3. Add the following code to this file, replacing $product_id with the actual ID of the product you want to disable:

<?php

// Include Magento's bootstrap file
require_once 'app/Mage.php';

// Start up the Magento application
Mage::init();

// Get all store IDs
$stores = Mage::app()->getStores(true);

foreach ($stores as $store) {
    // Get the current store ID
    $store_id = $store->getId();

    // Initialize the product status model
    $status_model = Mage::getModel('catalog/product_status');

    // Disable the product for the current store view
    $status_model->updateProductStatus($product_id, $store_id, Mage_Catalog_Model_Product_Status::STATUS_DISABLED);
}

// Print a success message
echo "Product ID: {$product_id} has been disabled across all store views.";

  1. Save and close the file.

  2. Run the script using the following command in your SSH terminal:

php disable_product.php

If everything is set up correctly, you should see a confirmation message indicating that the product has been disabled across all store views.

Verifying the Changes

To verify that the changes have taken effect, navigate to each of your store views and check if the desired product is still visible. It should no longer appear in search results or category lists.

Conclusion: Streamlining Product Management Across Stores

Disabling products programmatically across multiple Magento stores can be a powerful tool for managing your catalog effectively. By using this script, you can save time and ensure consistency across all regions or languages in your multi-store setup.

Remember to test the script thoroughly before deploying it on a production site and always have a backup plan in place to revert changes if needed.

For more advanced Magento solutions, consider exploring our services at Laravel Company. Our team of seasoned developers can help you optimize your Magento store for better performance and user experience.

Catalog Database Security Errors

Our network