Get product stock quantity in magento












10















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,
);
}









share|improve this question





























    10















    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,
    );
    }









    share|improve this question



























      10












      10








      10


      3






      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,
      );
      }









      share|improve this question
















      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,
      );
      }






      magento-1.9 products stock






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 13 '16 at 11:22









      Siarhey Uchukhlebau

      9,69192858




      9,69192858










      asked Mar 16 '16 at 4:44









      vellai duraivellai durai

      2652315




      2652315






















          4 Answers
          4






          active

          oldest

          votes


















          7














          You will need to join the table to get qty.



          See below code:



          $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(),
          );
          }



          How to get created attribute value here for eg i have created a attribute named size how to fetch that value




          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:



          $_product = Mage::getModel('catalog/product')->load($product->getId());
          $size = $_product->getSize();





          share|improve this answer


























          • how to get created attribute value here for eg i have created a attribute named size how to fetch that value

            – vellai durai
            Mar 16 '16 at 5:02











          • Try $product->getSize() or $product->getData('size')

            – Adarsh Khatri
            Mar 16 '16 at 5:03











          • Its returning null values only

            – vellai durai
            Mar 16 '16 at 5:07











          • Have you added your custom attribute in ->addAttributeToSelect? You have to tell what to select. otherwise just use ->addAttributeToSelect(*) instead. This will select everything related to product. If this doesn't work then check my updated answer shortly.

            – Adarsh Khatri
            Mar 16 '16 at 5:09













          • Yes i have added

            – vellai durai
            Mar 16 '16 at 5:10



















          16














          It's working for me.



          $products = Mage::getModel('catalog/product')->getCollection();
          foreach ($products as $_product) {
          $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
          echo $stock->getQty();
          echo $stock->getMinQty();
          echo $stock->getMinSaleQty();
          }





          share|improve this answer

































            5














            Adding stock information to product collections can be done with a single line:



            /* Mage_Catalog_Model_Resource_Product_Collection */
            $products->setFlag('require_stock_items', true);


            This flag is used in catalog_product_collection_load_after observer:



            /**
            * Add information about producs stock status to collection
            * Used in for product collection after load
            *
            * @param Varien_Event_Observer $observer
            * @return Mage_CatalogInventory_Model_Observer
            */
            public function addStockStatusToCollection($observer)
            {
            $productCollection = $observer->getEvent()->getCollection();
            if ($productCollection->hasFlag('require_stock_items')) {
            Mage::getModel('cataloginventory/stock')->addItemsToProducts($productCollection);
            } else {
            Mage::getModel('cataloginventory/stock_status')->addStockStatusToProducts($productCollection);
            }
            return $this;
            }


            If this flag is not set $product->getStockItem()->getData() has only is_in_stock set. With flag you can get qty, backorders, ... for every product in collection



            foreach ($products as $product) {
            echo $product->getStockItem()->getQty();
            }





            share|improve this answer

































              0














              You can can access the products stock quantity via StockItem like this:



              $_product->getStockItem()->getQty();


              Tested in template/catalog/product/view.phtml






              share|improve this answer























                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "479"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: false,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f106455%2fget-product-stock-quantity-in-magento%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                7














                You will need to join the table to get qty.



                See below code:



                $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(),
                );
                }



                How to get created attribute value here for eg i have created a attribute named size how to fetch that value




                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:



                $_product = Mage::getModel('catalog/product')->load($product->getId());
                $size = $_product->getSize();





                share|improve this answer


























                • how to get created attribute value here for eg i have created a attribute named size how to fetch that value

                  – vellai durai
                  Mar 16 '16 at 5:02











                • Try $product->getSize() or $product->getData('size')

                  – Adarsh Khatri
                  Mar 16 '16 at 5:03











                • Its returning null values only

                  – vellai durai
                  Mar 16 '16 at 5:07











                • Have you added your custom attribute in ->addAttributeToSelect? You have to tell what to select. otherwise just use ->addAttributeToSelect(*) instead. This will select everything related to product. If this doesn't work then check my updated answer shortly.

                  – Adarsh Khatri
                  Mar 16 '16 at 5:09













                • Yes i have added

                  – vellai durai
                  Mar 16 '16 at 5:10
















                7














                You will need to join the table to get qty.



                See below code:



                $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(),
                );
                }



                How to get created attribute value here for eg i have created a attribute named size how to fetch that value




                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:



                $_product = Mage::getModel('catalog/product')->load($product->getId());
                $size = $_product->getSize();





                share|improve this answer


























                • how to get created attribute value here for eg i have created a attribute named size how to fetch that value

                  – vellai durai
                  Mar 16 '16 at 5:02











                • Try $product->getSize() or $product->getData('size')

                  – Adarsh Khatri
                  Mar 16 '16 at 5:03











                • Its returning null values only

                  – vellai durai
                  Mar 16 '16 at 5:07











                • Have you added your custom attribute in ->addAttributeToSelect? You have to tell what to select. otherwise just use ->addAttributeToSelect(*) instead. This will select everything related to product. If this doesn't work then check my updated answer shortly.

                  – Adarsh Khatri
                  Mar 16 '16 at 5:09













                • Yes i have added

                  – vellai durai
                  Mar 16 '16 at 5:10














                7












                7








                7







                You will need to join the table to get qty.



                See below code:



                $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(),
                );
                }



                How to get created attribute value here for eg i have created a attribute named size how to fetch that value




                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:



                $_product = Mage::getModel('catalog/product')->load($product->getId());
                $size = $_product->getSize();





                share|improve this answer















                You will need to join the table to get qty.



                See below code:



                $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(),
                );
                }



                How to get created attribute value here for eg i have created a attribute named size how to fetch that value




                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:



                $_product = Mage::getModel('catalog/product')->load($product->getId());
                $size = $_product->getSize();






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Feb 3 '18 at 18:33









                sv3n

                9,79062354




                9,79062354










                answered Mar 16 '16 at 4:53









                Adarsh KhatriAdarsh Khatri

                6,70811644




                6,70811644













                • how to get created attribute value here for eg i have created a attribute named size how to fetch that value

                  – vellai durai
                  Mar 16 '16 at 5:02











                • Try $product->getSize() or $product->getData('size')

                  – Adarsh Khatri
                  Mar 16 '16 at 5:03











                • Its returning null values only

                  – vellai durai
                  Mar 16 '16 at 5:07











                • Have you added your custom attribute in ->addAttributeToSelect? You have to tell what to select. otherwise just use ->addAttributeToSelect(*) instead. This will select everything related to product. If this doesn't work then check my updated answer shortly.

                  – Adarsh Khatri
                  Mar 16 '16 at 5:09













                • Yes i have added

                  – vellai durai
                  Mar 16 '16 at 5:10



















                • how to get created attribute value here for eg i have created a attribute named size how to fetch that value

                  – vellai durai
                  Mar 16 '16 at 5:02











                • Try $product->getSize() or $product->getData('size')

                  – Adarsh Khatri
                  Mar 16 '16 at 5:03











                • Its returning null values only

                  – vellai durai
                  Mar 16 '16 at 5:07











                • Have you added your custom attribute in ->addAttributeToSelect? You have to tell what to select. otherwise just use ->addAttributeToSelect(*) instead. This will select everything related to product. If this doesn't work then check my updated answer shortly.

                  – Adarsh Khatri
                  Mar 16 '16 at 5:09













                • Yes i have added

                  – vellai durai
                  Mar 16 '16 at 5:10

















                how to get created attribute value here for eg i have created a attribute named size how to fetch that value

                – vellai durai
                Mar 16 '16 at 5:02





                how to get created attribute value here for eg i have created a attribute named size how to fetch that value

                – vellai durai
                Mar 16 '16 at 5:02













                Try $product->getSize() or $product->getData('size')

                – Adarsh Khatri
                Mar 16 '16 at 5:03





                Try $product->getSize() or $product->getData('size')

                – Adarsh Khatri
                Mar 16 '16 at 5:03













                Its returning null values only

                – vellai durai
                Mar 16 '16 at 5:07





                Its returning null values only

                – vellai durai
                Mar 16 '16 at 5:07













                Have you added your custom attribute in ->addAttributeToSelect? You have to tell what to select. otherwise just use ->addAttributeToSelect(*) instead. This will select everything related to product. If this doesn't work then check my updated answer shortly.

                – Adarsh Khatri
                Mar 16 '16 at 5:09







                Have you added your custom attribute in ->addAttributeToSelect? You have to tell what to select. otherwise just use ->addAttributeToSelect(*) instead. This will select everything related to product. If this doesn't work then check my updated answer shortly.

                – Adarsh Khatri
                Mar 16 '16 at 5:09















                Yes i have added

                – vellai durai
                Mar 16 '16 at 5:10





                Yes i have added

                – vellai durai
                Mar 16 '16 at 5:10













                16














                It's working for me.



                $products = Mage::getModel('catalog/product')->getCollection();
                foreach ($products as $_product) {
                $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
                echo $stock->getQty();
                echo $stock->getMinQty();
                echo $stock->getMinSaleQty();
                }





                share|improve this answer






























                  16














                  It's working for me.



                  $products = Mage::getModel('catalog/product')->getCollection();
                  foreach ($products as $_product) {
                  $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
                  echo $stock->getQty();
                  echo $stock->getMinQty();
                  echo $stock->getMinSaleQty();
                  }





                  share|improve this answer




























                    16












                    16








                    16







                    It's working for me.



                    $products = Mage::getModel('catalog/product')->getCollection();
                    foreach ($products as $_product) {
                    $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
                    echo $stock->getQty();
                    echo $stock->getMinQty();
                    echo $stock->getMinSaleQty();
                    }





                    share|improve this answer















                    It's working for me.



                    $products = Mage::getModel('catalog/product')->getCollection();
                    foreach ($products as $_product) {
                    $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
                    echo $stock->getQty();
                    echo $stock->getMinQty();
                    echo $stock->getMinSaleQty();
                    }






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 5 mins ago









                    Teja Bhagavan Kollepara

                    2,94841847




                    2,94841847










                    answered Mar 16 '16 at 4:56









                    Ajay PatelAjay Patel

                    9391427




                    9391427























                        5














                        Adding stock information to product collections can be done with a single line:



                        /* Mage_Catalog_Model_Resource_Product_Collection */
                        $products->setFlag('require_stock_items', true);


                        This flag is used in catalog_product_collection_load_after observer:



                        /**
                        * Add information about producs stock status to collection
                        * Used in for product collection after load
                        *
                        * @param Varien_Event_Observer $observer
                        * @return Mage_CatalogInventory_Model_Observer
                        */
                        public function addStockStatusToCollection($observer)
                        {
                        $productCollection = $observer->getEvent()->getCollection();
                        if ($productCollection->hasFlag('require_stock_items')) {
                        Mage::getModel('cataloginventory/stock')->addItemsToProducts($productCollection);
                        } else {
                        Mage::getModel('cataloginventory/stock_status')->addStockStatusToProducts($productCollection);
                        }
                        return $this;
                        }


                        If this flag is not set $product->getStockItem()->getData() has only is_in_stock set. With flag you can get qty, backorders, ... for every product in collection



                        foreach ($products as $product) {
                        echo $product->getStockItem()->getQty();
                        }





                        share|improve this answer






























                          5














                          Adding stock information to product collections can be done with a single line:



                          /* Mage_Catalog_Model_Resource_Product_Collection */
                          $products->setFlag('require_stock_items', true);


                          This flag is used in catalog_product_collection_load_after observer:



                          /**
                          * Add information about producs stock status to collection
                          * Used in for product collection after load
                          *
                          * @param Varien_Event_Observer $observer
                          * @return Mage_CatalogInventory_Model_Observer
                          */
                          public function addStockStatusToCollection($observer)
                          {
                          $productCollection = $observer->getEvent()->getCollection();
                          if ($productCollection->hasFlag('require_stock_items')) {
                          Mage::getModel('cataloginventory/stock')->addItemsToProducts($productCollection);
                          } else {
                          Mage::getModel('cataloginventory/stock_status')->addStockStatusToProducts($productCollection);
                          }
                          return $this;
                          }


                          If this flag is not set $product->getStockItem()->getData() has only is_in_stock set. With flag you can get qty, backorders, ... for every product in collection



                          foreach ($products as $product) {
                          echo $product->getStockItem()->getQty();
                          }





                          share|improve this answer




























                            5












                            5








                            5







                            Adding stock information to product collections can be done with a single line:



                            /* Mage_Catalog_Model_Resource_Product_Collection */
                            $products->setFlag('require_stock_items', true);


                            This flag is used in catalog_product_collection_load_after observer:



                            /**
                            * Add information about producs stock status to collection
                            * Used in for product collection after load
                            *
                            * @param Varien_Event_Observer $observer
                            * @return Mage_CatalogInventory_Model_Observer
                            */
                            public function addStockStatusToCollection($observer)
                            {
                            $productCollection = $observer->getEvent()->getCollection();
                            if ($productCollection->hasFlag('require_stock_items')) {
                            Mage::getModel('cataloginventory/stock')->addItemsToProducts($productCollection);
                            } else {
                            Mage::getModel('cataloginventory/stock_status')->addStockStatusToProducts($productCollection);
                            }
                            return $this;
                            }


                            If this flag is not set $product->getStockItem()->getData() has only is_in_stock set. With flag you can get qty, backorders, ... for every product in collection



                            foreach ($products as $product) {
                            echo $product->getStockItem()->getQty();
                            }





                            share|improve this answer















                            Adding stock information to product collections can be done with a single line:



                            /* Mage_Catalog_Model_Resource_Product_Collection */
                            $products->setFlag('require_stock_items', true);


                            This flag is used in catalog_product_collection_load_after observer:



                            /**
                            * Add information about producs stock status to collection
                            * Used in for product collection after load
                            *
                            * @param Varien_Event_Observer $observer
                            * @return Mage_CatalogInventory_Model_Observer
                            */
                            public function addStockStatusToCollection($observer)
                            {
                            $productCollection = $observer->getEvent()->getCollection();
                            if ($productCollection->hasFlag('require_stock_items')) {
                            Mage::getModel('cataloginventory/stock')->addItemsToProducts($productCollection);
                            } else {
                            Mage::getModel('cataloginventory/stock_status')->addStockStatusToProducts($productCollection);
                            }
                            return $this;
                            }


                            If this flag is not set $product->getStockItem()->getData() has only is_in_stock set. With flag you can get qty, backorders, ... for every product in collection



                            foreach ($products as $product) {
                            echo $product->getStockItem()->getQty();
                            }






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jan 17 '18 at 2:46

























                            answered Jan 15 '18 at 13:35









                            sv3nsv3n

                            9,79062354




                            9,79062354























                                0














                                You can can access the products stock quantity via StockItem like this:



                                $_product->getStockItem()->getQty();


                                Tested in template/catalog/product/view.phtml






                                share|improve this answer




























                                  0














                                  You can can access the products stock quantity via StockItem like this:



                                  $_product->getStockItem()->getQty();


                                  Tested in template/catalog/product/view.phtml






                                  share|improve this answer


























                                    0












                                    0








                                    0







                                    You can can access the products stock quantity via StockItem like this:



                                    $_product->getStockItem()->getQty();


                                    Tested in template/catalog/product/view.phtml






                                    share|improve this answer













                                    You can can access the products stock quantity via StockItem like this:



                                    $_product->getStockItem()->getQty();


                                    Tested in template/catalog/product/view.phtml







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Jan 15 '18 at 13:13









                                    Andreas RiedmüllerAndreas Riedmüller

                                    1416




                                    1416






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Magento Stack Exchange!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f106455%2fget-product-stock-quantity-in-magento%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        What other Star Trek series did the main TNG cast show up in?

                                        Berlina muro

                                        Berlina aerponto