I need to get several info from each single product in the catalog, so I used the Magento\Catalog\Model\ResourceModel\Product\CollectionFactory
to get a collection of products.
Iterating through them I notice I cannot get all the data related to each product.
E.g.
$product->getData('name')
returns the Product Tile$product->getData('qty')
dosen't work$product->getData('quantity_and_stock_status')
returns 1 (just the number like a string)
In the last example $product->getData('quantity_and_stock_status')
, if I load the product with Magento\Catalog\Model\Product
, then instead of returning 1, I get an array with 2 values qty
and is_in_stock
, which is what I want.
Just a quick note, loading each product with Magento\Catalog\Model\Product
is taking ages, so I'd avoid it.
Is it possible having all the info related to the product with the Product\CollectionFactory
?