B-219 Sec-55 Noida, India
+918010221733

Get all disabled products programmatically in Magento

Get all disabled products from Magento using product collection:

<?php
set_time_limit(0);
error_reporting(E_ALL ^ E_NOTICE);
ini_set(“display_errors”,’On’);

require_once ‘app/Mage.php’;
umask(0);
Mage::app(‘default’);

$products = Mage::getModel(‘catalog/product’)->getCollection()
    ->addAttributeToSelect(‘*’)
  ->addFieldToFilter(‘status’,Mage_Catalog_Model_Product_Status::
STATUS_DISABLED);

$products->load();
foreach($products as $product) {
    echo $product->getData(‘sku’).”<br />”;
    //var_dump($product->getStatus());
}
?>

Get all disabled products from Magento using Database SQL query:

<?php
set_time_limit(0);
error_reporting(E_ALL ^ E_NOTICE);
ini_set(“display_errors”,’On’);

require_once ‘app/Mage.php’;
umask(0);
Mage::app(‘default’);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

$conn = Mage::getSingleton(‘core/resource’)->getConnection(‘core_write’);

$catSQL = “SELECT *
FROM `itshot_catalog_product_entity_int`
WHERE `attribute_id` =84  // status=84 (see status id from attributes)
AND `value` =2  // disabled value=2
//AND `entity_id` >30970″; // if you want to show result from range
$categories = $conn->fetchAll($catSQL);
foreach ($categories as $product)
{
    $id = trim($product[“entity_id”]);
}
?>

(Visited 1,089 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.