1

Qty on the database tables cataloginventory_stock and cataloginventory_stock_item are different from Magento admin page. I'm assuming there is a problem to load qty from the database.

I want to know how to load qty information from database to Magento admin page.

Thank you

2 Answers 2

5
$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,
        'qty'           => $product->getQty(),
    );
}

Check this link for more Get product stock quantity in magento

7
  • can you tell me the path of this code?
    – Diny Na
    Jun 6, 2017 at 18:30
  • Which admin page do you want to load? Jun 6, 2017 at 18:44
  • on magento admin page....what do you mean which admin?
    – Diny Na
    Jun 6, 2017 at 18:46
  • Sorry , this code can help you to get product stock. You can use it for your problem . This is snippet of code. Jun 6, 2017 at 19:18
  • Which part of adming page , the qty is not right? Catalog grid? Admin Edit product ? Jun 6, 2017 at 19:19
2

3 tables are mainly used to manage the stock : cataloginventory_stock, cataloginventory_stock_item and cataloginventory_stock_status

If you need to get or update a product's stock quantity you will need to find the relevant line in the cataloginventory_stock_item table It's not normal that quantity show in Magento Admin page is different, do you use third party extension to manage stock like ERP ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.