Why my Disabled product collection gives empty array in magento 2?
-
14-04-2021 - |
سؤال
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);
لا تنتمي إلى magento.stackexchange