Question

I want to get disabled product id's in my system but it gives me an empty array.

Here is screenshot of my products.When i grab disabled product by using this code

$updatedproids = [];
    $productCollection = $this->_productCollectionFactory->create();
    $productCollection->setFlag('has_stock_status_filter', false);
    $productCollection;

    foreach ($productCollection as $product) {
        $updatedproids[] = $product->getId();
    }
print_r($updatedproids);

I think there should be an issue with Magento Saleable Quantity but i'm not sure why i didn't get this.

No correct solution

OTHER TIPS

Please try this below:

    $updatedproids = [];
    $productCollection = $this->_productCollectionFactory->create()->addAttributeToSelect('*');
    $productCollection->addAttributeToFilter('status', array('in'=>array(2)))

    foreach ($productCollection as $product) {
        $updatedproids[] = $product->getId();
    }

    print_r($updatedproids);
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top