- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2016
08:28 AM
06-08-2016
08:28 AM
How to get the product from Stock Item?
I make a dynamic quantity in a custom product and I need to get the product by id.
My class in my module:
class Item extends \Magento\CatalogInventory\Model\Stock\Item { public function getQty() { $_product = $objectManager->get('Magento\Catalog\Model\Product')->load($productId); $attr = $_product->getData('attribute_name'); return 123; } }
But after calling "load" magenta freezes. This is because in the method of load caused by my method, and there is begins recursion.
How can I get my attribute?
Labels:
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2016
04:40 AM
12-20-2016
04:40 AM
Re: How to get the product from Stock Item?
Same problem here. Did you find any solutions ?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2016
05:50 AM
12-20-2016
05:50 AM
Re: How to get the product from Stock Item?
Yes. I created my code with sql-commands and didn't use the repository or model.