0

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

4
$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

  • can you tell me the path of this code? – Diny Na Jun 6 '17 at 18:30
  • Which admin page do you want to load? – Ledian Hymetllari Jun 6 '17 at 18:44
  • on magento admin page....what do you mean which admin? – Diny Na Jun 6 '17 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. – Ledian Hymetllari Jun 6 '17 at 19:18
  • Which part of adming page , the qty is not right? Catalog grid? Admin Edit product ? – Ledian Hymetllari Jun 6 '17 at 19:19
0

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, privacy policy and cookie policy

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