문제

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.

올바른 솔루션이 없습니다

다른 팁

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top