Pergunta

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.

Nenhuma solução correta

Outras dicas

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);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top