Product Repository Shows 'Requested product doesn't exist' After Setting is_in_stock = 0Items don't turn out of stock when qty is 0Debug/Disable automatic set out of stock when lower qty reachedIs it possible to show in the products grid the length of time that the product has been out of stockProducts don't displayMagento2 - ProductRepository how to catch Exception if sku does not existConfigurable product and associated products are in stock. Associated products have quantity > 0, still showing Out of Stock in front end.Update Product programmatically - Invalid method MagentoEavModelEntityAttribute::isScopeGlobalMagento 2.2.5 creating simple product programmatically, Qty value not getting savedProduct doesn't change stock status until after the page reloadHow do I show child product quantity inside a config/grouped product

How would a developer who mostly fixed bugs for years at a company call out their contributions in their CV?

Why does Bran want to find Drogon?

Is there an idiom that means that you are in a very strong negotiation position in a negotiation?

Are there any German nonsense poems (Jabberwocky)?

Is "vegetable base" a common term in English?

Why is unzipped directory exactly 4.0k (much smaller than zipped file)?

How did NASA Langley end up with the first 737?

Can you still travel to America on the ESTA waiver program if you have been to Iran in transit?

The Maltese Falcon

Sorting with IComparable design

Why do Russians almost not use verbs of possession akin to "have"?

Why did other houses not demand this?

3 prong range outlet

Is there any chance a man can get the death penalty for causing a miscarriage?

What weight should be given to writers groups critiques?

Cardio work for Muay Thai fighters

Are cells guaranteed to get at least one mitochondrion when they divide?

Shorten or merge multiple lines of `&> /dev/null &`

Is there a simple example that empirical evidence is misleading?

Why did it take so long for Germany to allow electric scooters / e-rollers on the roads?

Which European Languages are not Indo-European?

Removing the last element of a list

Why did Jon Snow do this immoral act if he is so honorable?

What is the use case for non-breathable waterproof pants?



Product Repository Shows 'Requested product doesn't exist' After Setting is_in_stock = 0


Items don't turn out of stock when qty is 0Debug/Disable automatic set out of stock when lower qty reachedIs it possible to show in the products grid the length of time that the product has been out of stockProducts don't displayMagento2 - ProductRepository how to catch Exception if sku does not existConfigurable product and associated products are in stock. Associated products have quantity > 0, still showing Out of Stock in front end.Update Product programmatically - Invalid method MagentoEavModelEntityAttribute::isScopeGlobalMagento 2.2.5 creating simple product programmatically, Qty value not getting savedProduct doesn't change stock status until after the page reloadHow do I show child product quantity inside a config/grouped product






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I Have Loaded A Simple Product Using
MagentoCatalogModelProductRepository And Changed Its Quantity To 1 And Stock Status (is_in_stock) To 0,



Using Function $productStock->setQuantityAndStockStatus(['qty' => $correctedStock, 'is_in_stock' => $isInStock]);



After This Am Not Able To Load The Product Programmatically , It Shows Following Error.




`1 exception(s):
Exception #0 (MagentoFrameworkExceptionNoSuchEntityException): Requested product doesn't exist




Using Magento CE 2.1.2










share|improve this question






















  • I think you miss some settings . 1st check is your product enable or not.

    – Debasis Chakraborty
    Nov 29 '16 at 11:19











  • its enabled, i have checked.

    – Rahul v Ramesh
    Nov 29 '16 at 11:21











  • after setting is_in_status = 0 , product will be disabled automatically ?

    – Rahul v Ramesh
    Nov 29 '16 at 11:21











  • set is_in_stock to 1 . I think 0 means out of stock

    – Debasis Chakraborty
    Nov 29 '16 at 11:25











  • Yah , I Want To make It out of stock , and set qty 1 because of some m2 bug

    – Rahul v Ramesh
    Nov 29 '16 at 16:45

















1















I Have Loaded A Simple Product Using
MagentoCatalogModelProductRepository And Changed Its Quantity To 1 And Stock Status (is_in_stock) To 0,



Using Function $productStock->setQuantityAndStockStatus(['qty' => $correctedStock, 'is_in_stock' => $isInStock]);



After This Am Not Able To Load The Product Programmatically , It Shows Following Error.




`1 exception(s):
Exception #0 (MagentoFrameworkExceptionNoSuchEntityException): Requested product doesn't exist




Using Magento CE 2.1.2










share|improve this question






















  • I think you miss some settings . 1st check is your product enable or not.

    – Debasis Chakraborty
    Nov 29 '16 at 11:19











  • its enabled, i have checked.

    – Rahul v Ramesh
    Nov 29 '16 at 11:21











  • after setting is_in_status = 0 , product will be disabled automatically ?

    – Rahul v Ramesh
    Nov 29 '16 at 11:21











  • set is_in_stock to 1 . I think 0 means out of stock

    – Debasis Chakraborty
    Nov 29 '16 at 11:25











  • Yah , I Want To make It out of stock , and set qty 1 because of some m2 bug

    – Rahul v Ramesh
    Nov 29 '16 at 16:45













1












1








1


0






I Have Loaded A Simple Product Using
MagentoCatalogModelProductRepository And Changed Its Quantity To 1 And Stock Status (is_in_stock) To 0,



Using Function $productStock->setQuantityAndStockStatus(['qty' => $correctedStock, 'is_in_stock' => $isInStock]);



After This Am Not Able To Load The Product Programmatically , It Shows Following Error.




`1 exception(s):
Exception #0 (MagentoFrameworkExceptionNoSuchEntityException): Requested product doesn't exist




Using Magento CE 2.1.2










share|improve this question














I Have Loaded A Simple Product Using
MagentoCatalogModelProductRepository And Changed Its Quantity To 1 And Stock Status (is_in_stock) To 0,



Using Function $productStock->setQuantityAndStockStatus(['qty' => $correctedStock, 'is_in_stock' => $isInStock]);



After This Am Not Able To Load The Product Programmatically , It Shows Following Error.




`1 exception(s):
Exception #0 (MagentoFrameworkExceptionNoSuchEntityException): Requested product doesn't exist




Using Magento CE 2.1.2







magento2 stock






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 29 '16 at 11:12









Rahul v RameshRahul v Ramesh

4119




4119












  • I think you miss some settings . 1st check is your product enable or not.

    – Debasis Chakraborty
    Nov 29 '16 at 11:19











  • its enabled, i have checked.

    – Rahul v Ramesh
    Nov 29 '16 at 11:21











  • after setting is_in_status = 0 , product will be disabled automatically ?

    – Rahul v Ramesh
    Nov 29 '16 at 11:21











  • set is_in_stock to 1 . I think 0 means out of stock

    – Debasis Chakraborty
    Nov 29 '16 at 11:25











  • Yah , I Want To make It out of stock , and set qty 1 because of some m2 bug

    – Rahul v Ramesh
    Nov 29 '16 at 16:45

















  • I think you miss some settings . 1st check is your product enable or not.

    – Debasis Chakraborty
    Nov 29 '16 at 11:19











  • its enabled, i have checked.

    – Rahul v Ramesh
    Nov 29 '16 at 11:21











  • after setting is_in_status = 0 , product will be disabled automatically ?

    – Rahul v Ramesh
    Nov 29 '16 at 11:21











  • set is_in_stock to 1 . I think 0 means out of stock

    – Debasis Chakraborty
    Nov 29 '16 at 11:25











  • Yah , I Want To make It out of stock , and set qty 1 because of some m2 bug

    – Rahul v Ramesh
    Nov 29 '16 at 16:45
















I think you miss some settings . 1st check is your product enable or not.

– Debasis Chakraborty
Nov 29 '16 at 11:19





I think you miss some settings . 1st check is your product enable or not.

– Debasis Chakraborty
Nov 29 '16 at 11:19













its enabled, i have checked.

– Rahul v Ramesh
Nov 29 '16 at 11:21





its enabled, i have checked.

– Rahul v Ramesh
Nov 29 '16 at 11:21













after setting is_in_status = 0 , product will be disabled automatically ?

– Rahul v Ramesh
Nov 29 '16 at 11:21





after setting is_in_status = 0 , product will be disabled automatically ?

– Rahul v Ramesh
Nov 29 '16 at 11:21













set is_in_stock to 1 . I think 0 means out of stock

– Debasis Chakraborty
Nov 29 '16 at 11:25





set is_in_stock to 1 . I think 0 means out of stock

– Debasis Chakraborty
Nov 29 '16 at 11:25













Yah , I Want To make It out of stock , and set qty 1 because of some m2 bug

– Rahul v Ramesh
Nov 29 '16 at 16:45





Yah , I Want To make It out of stock , and set qty 1 because of some m2 bug

– Rahul v Ramesh
Nov 29 '16 at 16:45










2 Answers
2






active

oldest

votes


















0














Go to admin > Stores > configuration > Catalog > Inventory > Stock Options



Set Display Out of Stock Products to NO






share|improve this answer






























    0














    You can create a Helper class (as given below ) to update product inventory as you want .



    Assume you are using a custom extension Company_MyModule



    <?php
    namespace CompanyMyModuleHelper;

    use MagentoFrameworkAppFilesystemDirectoryList;

    class Data extends MagentoFrameworkAppHelperAbstractHelper


    /**
    * @var MagentoCatalogApiProductRepositoryInterface
    */
    protected $_productRepository;

    /**
    * @var MagentoCatalogInventoryApiStockStateInterface
    */
    protected $_stockStateInterface;

    /**
    * @var MagentoCatalogInventoryApiStockRegistryInterface
    */
    protected $_stockRegistry;



    /**
    * @param MagentoFrameworkAppHelperContext $context
    * @param MagentoCatalogApiProductRepositoryInterface $productRepository
    * @param MagentoCatalogInventoryApiStockStateInterface $stockStateInterface,
    * @param MagentoCatalogInventoryApiStockRegistryInterface $stockRegistry
    */
    public function __construct(
    MagentoFrameworkAppHelperContext $context,
    MagentoCatalogApiProductRepositoryInterface $productRepository,
    MagentoCatalogInventoryApiStockStateInterface $stockStateInterface,
    MagentoCatalogInventoryApiStockRegistryInterface $stockRegistry
    )
    $this->_productRepository = $productRepository;
    $this->_stockStateInterface = $stockStateInterface;
    $this->_stockRegistry = $stockRegistry;
    parent::__construct($context);


    /**
    * For Update stock of product
    * @param int $productId which stock you want to update
    * @param array $stockData your updated data
    * @return void
    */
    public function updateProductStock($productId,$stockData)
    $product = $this->_productRepository->getById($productId); //load product which you want to update stock
    $productSku = $product->getSku();
    $stockItem = $this->_stockRegistry->getStockItemBySku($productSku); // load stock of that product by SKU
    $stockItem->setIsInStock($stockData['is_in_stock']); //set updated data as your requirement
    $stockItem->setQty($stockData['qty']); //set updated quantity
    $stockItem->setManageStock($stockData['manage_stock']);
    $this->_stockRegistry->updateStockItemBySku($productSku,$stockItem);







    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%2f147992%2fproduct-repository-shows-requested-product-doesnt-exist-after-setting-is-in-s%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Go to admin > Stores > configuration > Catalog > Inventory > Stock Options



      Set Display Out of Stock Products to NO






      share|improve this answer



























        0














        Go to admin > Stores > configuration > Catalog > Inventory > Stock Options



        Set Display Out of Stock Products to NO






        share|improve this answer

























          0












          0








          0







          Go to admin > Stores > configuration > Catalog > Inventory > Stock Options



          Set Display Out of Stock Products to NO






          share|improve this answer













          Go to admin > Stores > configuration > Catalog > Inventory > Stock Options



          Set Display Out of Stock Products to NO







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 29 '16 at 11:45









          chiragchirag

          2,1751830




          2,1751830























              0














              You can create a Helper class (as given below ) to update product inventory as you want .



              Assume you are using a custom extension Company_MyModule



              <?php
              namespace CompanyMyModuleHelper;

              use MagentoFrameworkAppFilesystemDirectoryList;

              class Data extends MagentoFrameworkAppHelperAbstractHelper


              /**
              * @var MagentoCatalogApiProductRepositoryInterface
              */
              protected $_productRepository;

              /**
              * @var MagentoCatalogInventoryApiStockStateInterface
              */
              protected $_stockStateInterface;

              /**
              * @var MagentoCatalogInventoryApiStockRegistryInterface
              */
              protected $_stockRegistry;



              /**
              * @param MagentoFrameworkAppHelperContext $context
              * @param MagentoCatalogApiProductRepositoryInterface $productRepository
              * @param MagentoCatalogInventoryApiStockStateInterface $stockStateInterface,
              * @param MagentoCatalogInventoryApiStockRegistryInterface $stockRegistry
              */
              public function __construct(
              MagentoFrameworkAppHelperContext $context,
              MagentoCatalogApiProductRepositoryInterface $productRepository,
              MagentoCatalogInventoryApiStockStateInterface $stockStateInterface,
              MagentoCatalogInventoryApiStockRegistryInterface $stockRegistry
              )
              $this->_productRepository = $productRepository;
              $this->_stockStateInterface = $stockStateInterface;
              $this->_stockRegistry = $stockRegistry;
              parent::__construct($context);


              /**
              * For Update stock of product
              * @param int $productId which stock you want to update
              * @param array $stockData your updated data
              * @return void
              */
              public function updateProductStock($productId,$stockData)
              $product = $this->_productRepository->getById($productId); //load product which you want to update stock
              $productSku = $product->getSku();
              $stockItem = $this->_stockRegistry->getStockItemBySku($productSku); // load stock of that product by SKU
              $stockItem->setIsInStock($stockData['is_in_stock']); //set updated data as your requirement
              $stockItem->setQty($stockData['qty']); //set updated quantity
              $stockItem->setManageStock($stockData['manage_stock']);
              $this->_stockRegistry->updateStockItemBySku($productSku,$stockItem);







              share|improve this answer



























                0














                You can create a Helper class (as given below ) to update product inventory as you want .



                Assume you are using a custom extension Company_MyModule



                <?php
                namespace CompanyMyModuleHelper;

                use MagentoFrameworkAppFilesystemDirectoryList;

                class Data extends MagentoFrameworkAppHelperAbstractHelper


                /**
                * @var MagentoCatalogApiProductRepositoryInterface
                */
                protected $_productRepository;

                /**
                * @var MagentoCatalogInventoryApiStockStateInterface
                */
                protected $_stockStateInterface;

                /**
                * @var MagentoCatalogInventoryApiStockRegistryInterface
                */
                protected $_stockRegistry;



                /**
                * @param MagentoFrameworkAppHelperContext $context
                * @param MagentoCatalogApiProductRepositoryInterface $productRepository
                * @param MagentoCatalogInventoryApiStockStateInterface $stockStateInterface,
                * @param MagentoCatalogInventoryApiStockRegistryInterface $stockRegistry
                */
                public function __construct(
                MagentoFrameworkAppHelperContext $context,
                MagentoCatalogApiProductRepositoryInterface $productRepository,
                MagentoCatalogInventoryApiStockStateInterface $stockStateInterface,
                MagentoCatalogInventoryApiStockRegistryInterface $stockRegistry
                )
                $this->_productRepository = $productRepository;
                $this->_stockStateInterface = $stockStateInterface;
                $this->_stockRegistry = $stockRegistry;
                parent::__construct($context);


                /**
                * For Update stock of product
                * @param int $productId which stock you want to update
                * @param array $stockData your updated data
                * @return void
                */
                public function updateProductStock($productId,$stockData)
                $product = $this->_productRepository->getById($productId); //load product which you want to update stock
                $productSku = $product->getSku();
                $stockItem = $this->_stockRegistry->getStockItemBySku($productSku); // load stock of that product by SKU
                $stockItem->setIsInStock($stockData['is_in_stock']); //set updated data as your requirement
                $stockItem->setQty($stockData['qty']); //set updated quantity
                $stockItem->setManageStock($stockData['manage_stock']);
                $this->_stockRegistry->updateStockItemBySku($productSku,$stockItem);







                share|improve this answer

























                  0












                  0








                  0







                  You can create a Helper class (as given below ) to update product inventory as you want .



                  Assume you are using a custom extension Company_MyModule



                  <?php
                  namespace CompanyMyModuleHelper;

                  use MagentoFrameworkAppFilesystemDirectoryList;

                  class Data extends MagentoFrameworkAppHelperAbstractHelper


                  /**
                  * @var MagentoCatalogApiProductRepositoryInterface
                  */
                  protected $_productRepository;

                  /**
                  * @var MagentoCatalogInventoryApiStockStateInterface
                  */
                  protected $_stockStateInterface;

                  /**
                  * @var MagentoCatalogInventoryApiStockRegistryInterface
                  */
                  protected $_stockRegistry;



                  /**
                  * @param MagentoFrameworkAppHelperContext $context
                  * @param MagentoCatalogApiProductRepositoryInterface $productRepository
                  * @param MagentoCatalogInventoryApiStockStateInterface $stockStateInterface,
                  * @param MagentoCatalogInventoryApiStockRegistryInterface $stockRegistry
                  */
                  public function __construct(
                  MagentoFrameworkAppHelperContext $context,
                  MagentoCatalogApiProductRepositoryInterface $productRepository,
                  MagentoCatalogInventoryApiStockStateInterface $stockStateInterface,
                  MagentoCatalogInventoryApiStockRegistryInterface $stockRegistry
                  )
                  $this->_productRepository = $productRepository;
                  $this->_stockStateInterface = $stockStateInterface;
                  $this->_stockRegistry = $stockRegistry;
                  parent::__construct($context);


                  /**
                  * For Update stock of product
                  * @param int $productId which stock you want to update
                  * @param array $stockData your updated data
                  * @return void
                  */
                  public function updateProductStock($productId,$stockData)
                  $product = $this->_productRepository->getById($productId); //load product which you want to update stock
                  $productSku = $product->getSku();
                  $stockItem = $this->_stockRegistry->getStockItemBySku($productSku); // load stock of that product by SKU
                  $stockItem->setIsInStock($stockData['is_in_stock']); //set updated data as your requirement
                  $stockItem->setQty($stockData['qty']); //set updated quantity
                  $stockItem->setManageStock($stockData['manage_stock']);
                  $this->_stockRegistry->updateStockItemBySku($productSku,$stockItem);







                  share|improve this answer













                  You can create a Helper class (as given below ) to update product inventory as you want .



                  Assume you are using a custom extension Company_MyModule



                  <?php
                  namespace CompanyMyModuleHelper;

                  use MagentoFrameworkAppFilesystemDirectoryList;

                  class Data extends MagentoFrameworkAppHelperAbstractHelper


                  /**
                  * @var MagentoCatalogApiProductRepositoryInterface
                  */
                  protected $_productRepository;

                  /**
                  * @var MagentoCatalogInventoryApiStockStateInterface
                  */
                  protected $_stockStateInterface;

                  /**
                  * @var MagentoCatalogInventoryApiStockRegistryInterface
                  */
                  protected $_stockRegistry;



                  /**
                  * @param MagentoFrameworkAppHelperContext $context
                  * @param MagentoCatalogApiProductRepositoryInterface $productRepository
                  * @param MagentoCatalogInventoryApiStockStateInterface $stockStateInterface,
                  * @param MagentoCatalogInventoryApiStockRegistryInterface $stockRegistry
                  */
                  public function __construct(
                  MagentoFrameworkAppHelperContext $context,
                  MagentoCatalogApiProductRepositoryInterface $productRepository,
                  MagentoCatalogInventoryApiStockStateInterface $stockStateInterface,
                  MagentoCatalogInventoryApiStockRegistryInterface $stockRegistry
                  )
                  $this->_productRepository = $productRepository;
                  $this->_stockStateInterface = $stockStateInterface;
                  $this->_stockRegistry = $stockRegistry;
                  parent::__construct($context);


                  /**
                  * For Update stock of product
                  * @param int $productId which stock you want to update
                  * @param array $stockData your updated data
                  * @return void
                  */
                  public function updateProductStock($productId,$stockData)
                  $product = $this->_productRepository->getById($productId); //load product which you want to update stock
                  $productSku = $product->getSku();
                  $stockItem = $this->_stockRegistry->getStockItemBySku($productSku); // load stock of that product by SKU
                  $stockItem->setIsInStock($stockData['is_in_stock']); //set updated data as your requirement
                  $stockItem->setQty($stockData['qty']); //set updated quantity
                  $stockItem->setManageStock($stockData['manage_stock']);
                  $this->_stockRegistry->updateStockItemBySku($productSku,$stockItem);








                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 3 '18 at 13:43









                  Pritam Info 24Pritam Info 24

                  1,092127




                  1,092127



























                      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%2f147992%2fproduct-repository-shows-requested-product-doesnt-exist-after-setting-is-in-s%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

                      Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

                      Log in Navigation menu

                      Invalid response line returned from server: HTTP/2 401 | ErrorPlease Please Help With Error 500 Internal Server Error after upgrading from 1.7 to 1.9Unable to place new customer orders in admin backendMagento - For “Manage Categories” Forbidden You do not have permission to access this documentHTTP ERROR 500 when using require(_once) app/Mage.phpMemcached causing Web Setup Wizard ErrorCould not create an acl object: Invalid XMLAn error occurred on the server. Please try to place the order againInvalid response line returned from server: HTTP/2 200 - message after update to 2.1.7Magento-CE 2.3.0 installation error on XamppMagento 2.2.6- After Migration all default Payment Methods are not working fine