I need to get product stock quantity for the item, how to get that
$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToSelect(array('name', 'thumbnail', 'weight' ,'price','description'));
foreach ($products as $product) {
$p['products'][] = array(
'id' => $product->getId(),
'sku' => $product->getSku(),
'name' => $product->getName(),
'description' => $product->getDescription(),
'weight' => $product->getWeight(),
'created at' => $product->getCreatedAt(),
'pirce' => Mage::helper('core')->currency($product->getPrice(), true, false), //." ".$currencyCode,
);
}
Best Answer
You will need to join the table to get qty.
See below code:
UPDATE (Although you should ask in another qst, but I will answer here for you.)
To get custom attribute you will need to add attribute in
->addAttributeToSelect
section.Still doesn't work?
You might need to load a product model as sometimes I've experienced that not all custom attributes are attached when you pull it out of a collection (intended for performance reasons I guess). Something like: