Can't getStockItem magento 2.3.1Magento 2.3.1 installation ErrorIssue while generating db_schema file for existing module Magento 2.3.1Magento 2.3.1 Incompatible argument typeCan't access admin after update Magento 2.3.1Magento 2.3.1 - Changed PayPal Express ButtonMagento 2.3.1 update issueMagento 2.3.1 server resources requirementsCan't find ElasticSearch 6.0+ option in magento 2.3.1 backend (CE)Magento 2.3.1 compare and product rating disable?magento 2.3.1 elastic search index name
Why adjustbox needs a tweak of raise=-0.3ex with enumitem?
Speaker impedance: rewiring four 8 Ω speakers for use with 8 Ω amp output
Deflecting lasers with lightsabers
Can I say "Gesundheit" if someone is coughing?
Using Forstner bits instead of hole saws
How do people drown while wearing a life jacket?
How to handle many times series?
Partial Fractions: Why does this shortcut method work?
Does the problem of P vs NP come under the category of Operational Research?
Astable 555 circuit not oscillating
Being told my "network" isn't PCI compliant. I don't even have a server! Do I have to comply?
Can you shove a friendly creature?
Why do player start with fighting for the corners in go?
Skipping same old introductions
Why is the Vasa Museum in Stockholm so Popular?
How were x-ray diffraction patterns deciphered before computers?
Why does BezierFunction not follow BezierCurve at npts>4?
Is law enforcement responsible for damages made by a search warrant?
What is a summary of basic Jewish metaphysics or theology?
Search and replace a substring only if another substring is not present
How to avoid a lengthy conversation with someone from the neighborhood I don't share interests with
how to change ^L code in many files in ubuntu?
Gödel's paradox: Why is "a proof that some universal statement is unprovable" not a valid proof that this statement is true?
Has J.J.Jameson ever found out that Peter Parker is Spider-Man?
Can't getStockItem magento 2.3.1
Magento 2.3.1 installation ErrorIssue while generating db_schema file for existing module Magento 2.3.1Magento 2.3.1 Incompatible argument typeCan't access admin after update Magento 2.3.1Magento 2.3.1 - Changed PayPal Express ButtonMagento 2.3.1 update issueMagento 2.3.1 server resources requirementsCan't find ElasticSearch 6.0+ option in magento 2.3.1 backend (CE)Magento 2.3.1 compare and product rating disable?magento 2.3.1 elastic search index name
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Block
namespace VendorExtensionBlockProduct;
use MagentoFrameworkViewElementTemplate;
class Stickycart extends Template
protected $_registry;
protected $_stockItemRepository;
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoCatalogInventoryModelStockStockItemRepository $stockItemRepository,
array $data = []
)
$this->_registry = $registry;
$this->_stockItemRepository = $stockItemRepository;
parent::__construct($context, $data);
public function getCurrentProduct()
return $this->_registry->registry('current_product');
public function getStockItem($productId)
return $this->_stockItemRepository->get($productId);
Template
$currentProduct = $block->getCurrentProduct();
$id = $currentProduct->getId();
$_productStock = $block->getStockItem($id);
if($_productStock->getIsInStock())
...
But it show a bug:
The stock item with the "140" ID wasn't found. Verify the ID and try again.
I have checked that product in backend in Catalog but it's instock with qty is 465.
stock magento2.3.1 stock-status
add a comment |
Block
namespace VendorExtensionBlockProduct;
use MagentoFrameworkViewElementTemplate;
class Stickycart extends Template
protected $_registry;
protected $_stockItemRepository;
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoCatalogInventoryModelStockStockItemRepository $stockItemRepository,
array $data = []
)
$this->_registry = $registry;
$this->_stockItemRepository = $stockItemRepository;
parent::__construct($context, $data);
public function getCurrentProduct()
return $this->_registry->registry('current_product');
public function getStockItem($productId)
return $this->_stockItemRepository->get($productId);
Template
$currentProduct = $block->getCurrentProduct();
$id = $currentProduct->getId();
$_productStock = $block->getStockItem($id);
if($_productStock->getIsInStock())
...
But it show a bug:
The stock item with the "140" ID wasn't found. Verify the ID and try again.
I have checked that product in backend in Catalog but it's instock with qty is 465.
stock magento2.3.1 stock-status
check if that product id is 140
– Mohit Rane
Jul 25 at 4:44
Yes, Please check my screen: prntscr.com/ojpqa4
– David Duong
Jul 25 at 4:48
check my answer.
– Mohit Rane
Jul 25 at 4:50
add a comment |
Block
namespace VendorExtensionBlockProduct;
use MagentoFrameworkViewElementTemplate;
class Stickycart extends Template
protected $_registry;
protected $_stockItemRepository;
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoCatalogInventoryModelStockStockItemRepository $stockItemRepository,
array $data = []
)
$this->_registry = $registry;
$this->_stockItemRepository = $stockItemRepository;
parent::__construct($context, $data);
public function getCurrentProduct()
return $this->_registry->registry('current_product');
public function getStockItem($productId)
return $this->_stockItemRepository->get($productId);
Template
$currentProduct = $block->getCurrentProduct();
$id = $currentProduct->getId();
$_productStock = $block->getStockItem($id);
if($_productStock->getIsInStock())
...
But it show a bug:
The stock item with the "140" ID wasn't found. Verify the ID and try again.
I have checked that product in backend in Catalog but it's instock with qty is 465.
stock magento2.3.1 stock-status
Block
namespace VendorExtensionBlockProduct;
use MagentoFrameworkViewElementTemplate;
class Stickycart extends Template
protected $_registry;
protected $_stockItemRepository;
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoCatalogInventoryModelStockStockItemRepository $stockItemRepository,
array $data = []
)
$this->_registry = $registry;
$this->_stockItemRepository = $stockItemRepository;
parent::__construct($context, $data);
public function getCurrentProduct()
return $this->_registry->registry('current_product');
public function getStockItem($productId)
return $this->_stockItemRepository->get($productId);
Template
$currentProduct = $block->getCurrentProduct();
$id = $currentProduct->getId();
$_productStock = $block->getStockItem($id);
if($_productStock->getIsInStock())
...
But it show a bug:
The stock item with the "140" ID wasn't found. Verify the ID and try again.
I have checked that product in backend in Catalog but it's instock with qty is 465.
stock magento2.3.1 stock-status
stock magento2.3.1 stock-status
asked Jul 25 at 4:26
David DuongDavid Duong
778 bronze badges
778 bronze badges
check if that product id is 140
– Mohit Rane
Jul 25 at 4:44
Yes, Please check my screen: prntscr.com/ojpqa4
– David Duong
Jul 25 at 4:48
check my answer.
– Mohit Rane
Jul 25 at 4:50
add a comment |
check if that product id is 140
– Mohit Rane
Jul 25 at 4:44
Yes, Please check my screen: prntscr.com/ojpqa4
– David Duong
Jul 25 at 4:48
check my answer.
– Mohit Rane
Jul 25 at 4:50
check if that product id is 140
– Mohit Rane
Jul 25 at 4:44
check if that product id is 140
– Mohit Rane
Jul 25 at 4:44
Yes, Please check my screen: prntscr.com/ojpqa4
– David Duong
Jul 25 at 4:48
Yes, Please check my screen: prntscr.com/ojpqa4
– David Duong
Jul 25 at 4:48
check my answer.
– Mohit Rane
Jul 25 at 4:50
check my answer.
– Mohit Rane
Jul 25 at 4:50
add a comment |
1 Answer
1
active
oldest
votes
Try using this MagentoCatalogInventoryModelStockStockItemRepository
Update your code with following code
namespace VendorExtensionBlockProduct;
use MagentoFrameworkViewElementTemplate;
class Stickycart extends Template
protected $_registry;
protected $stockRegistry;
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoCatalogInventoryApiStockRegistryInterface $stockRegistry,
array $data = []
)
$this->_registry = $registry;
$this->stockRegistry = $stockRegistry;
parent::__construct($context, $data);
public function getCurrentProduct()
return $this->_registry->registry('current_product');
public function getStockItem($productId)
return $this->stockRegistry->getStockItem($productId);
Hope it Helps.
It work fine. Thank you!
– David Duong
Jul 25 at 11:48
1
glad it worked.
– Mohit Rane
Jul 25 at 11:51
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f283236%2fcant-getstockitem-magento-2-3-1%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try using this MagentoCatalogInventoryModelStockStockItemRepository
Update your code with following code
namespace VendorExtensionBlockProduct;
use MagentoFrameworkViewElementTemplate;
class Stickycart extends Template
protected $_registry;
protected $stockRegistry;
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoCatalogInventoryApiStockRegistryInterface $stockRegistry,
array $data = []
)
$this->_registry = $registry;
$this->stockRegistry = $stockRegistry;
parent::__construct($context, $data);
public function getCurrentProduct()
return $this->_registry->registry('current_product');
public function getStockItem($productId)
return $this->stockRegistry->getStockItem($productId);
Hope it Helps.
It work fine. Thank you!
– David Duong
Jul 25 at 11:48
1
glad it worked.
– Mohit Rane
Jul 25 at 11:51
add a comment |
Try using this MagentoCatalogInventoryModelStockStockItemRepository
Update your code with following code
namespace VendorExtensionBlockProduct;
use MagentoFrameworkViewElementTemplate;
class Stickycart extends Template
protected $_registry;
protected $stockRegistry;
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoCatalogInventoryApiStockRegistryInterface $stockRegistry,
array $data = []
)
$this->_registry = $registry;
$this->stockRegistry = $stockRegistry;
parent::__construct($context, $data);
public function getCurrentProduct()
return $this->_registry->registry('current_product');
public function getStockItem($productId)
return $this->stockRegistry->getStockItem($productId);
Hope it Helps.
It work fine. Thank you!
– David Duong
Jul 25 at 11:48
1
glad it worked.
– Mohit Rane
Jul 25 at 11:51
add a comment |
Try using this MagentoCatalogInventoryModelStockStockItemRepository
Update your code with following code
namespace VendorExtensionBlockProduct;
use MagentoFrameworkViewElementTemplate;
class Stickycart extends Template
protected $_registry;
protected $stockRegistry;
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoCatalogInventoryApiStockRegistryInterface $stockRegistry,
array $data = []
)
$this->_registry = $registry;
$this->stockRegistry = $stockRegistry;
parent::__construct($context, $data);
public function getCurrentProduct()
return $this->_registry->registry('current_product');
public function getStockItem($productId)
return $this->stockRegistry->getStockItem($productId);
Hope it Helps.
Try using this MagentoCatalogInventoryModelStockStockItemRepository
Update your code with following code
namespace VendorExtensionBlockProduct;
use MagentoFrameworkViewElementTemplate;
class Stickycart extends Template
protected $_registry;
protected $stockRegistry;
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoCatalogInventoryApiStockRegistryInterface $stockRegistry,
array $data = []
)
$this->_registry = $registry;
$this->stockRegistry = $stockRegistry;
parent::__construct($context, $data);
public function getCurrentProduct()
return $this->_registry->registry('current_product');
public function getStockItem($productId)
return $this->stockRegistry->getStockItem($productId);
Hope it Helps.
edited Jul 25 at 4:53
answered Jul 25 at 4:47
Mohit RaneMohit Rane
1,17718 bronze badges
1,17718 bronze badges
It work fine. Thank you!
– David Duong
Jul 25 at 11:48
1
glad it worked.
– Mohit Rane
Jul 25 at 11:51
add a comment |
It work fine. Thank you!
– David Duong
Jul 25 at 11:48
1
glad it worked.
– Mohit Rane
Jul 25 at 11:51
It work fine. Thank you!
– David Duong
Jul 25 at 11:48
It work fine. Thank you!
– David Duong
Jul 25 at 11:48
1
1
glad it worked.
– Mohit Rane
Jul 25 at 11:51
glad it worked.
– Mohit Rane
Jul 25 at 11:51
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f283236%2fcant-getstockitem-magento-2-3-1%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
check if that product id is 140
– Mohit Rane
Jul 25 at 4:44
Yes, Please check my screen: prntscr.com/ojpqa4
– David Duong
Jul 25 at 4:48
check my answer.
– Mohit Rane
Jul 25 at 4:50