Skip to content

Instantly share code, notes, and snippets.

@gelanivishal
Created December 31, 2016 17:45
Show Gist options
  • Save gelanivishal/efa33ef3586c918ced4b65aa0189cb6f to your computer and use it in GitHub Desktop.
Save gelanivishal/efa33ef3586c918ced4b65aa0189cb6f to your computer and use it in GitHub Desktop.
Load product by product id in listing #M2
<?php
// PS: Do not use *load/save* methods directly, instead use related repositoryinterface.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$load_product=$objectManager->get('Magento\Catalog\Api\ProductRepositoryInterface');
$_product = $load_product->getById($_single_product_id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment