Created
November 29, 2016 16:11
-
-
Save gelanivishal/2f806b8195112ce41d4543a7da8c8cb6 to your computer and use it in GitHub Desktop.
Get product stock quantity in magento
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$products = Mage::getModel('catalog/product') | |
->getCollection() | |
//->addAttributeToSelect('*') | |
->addAttributeToSelect(array('name', 'thumbnail', 'weight' ,'price','description')) | |
->joinField('qty', | |
'cataloginventory/stock_item', | |
'qty', | |
'product_id=entity_id', | |
'{{table}}.stock_id=1', | |
'left'); | |
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, | |
//get qty | |
'qty' => $product->getQty(), | |
); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment