Magento2 – Magento 2 load product by id
Magento2 – Magento 2 load product by id : In magento 1.x we use Mage::getModel(‘catalog/product’) to load the product but in magento 2.0 it is different than this. Here in this tutorial we are going to explain how you can load the product by product id.
Magento2 – Magento 2 load product by id
You can load the product by product id simply as below –
Magento2 – Magento 2 load product by id :
$productId = 100; $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->get('Magento\Catalog\Model\Product')->load($productId); |
The example loads the product object from product id.
Advertisements