如何从magento2或magento2.0中的产品ID获取产品信息? [英] How to get product information from product id in magento2 or magento2.0?

查看:390
本文介绍了如何从magento2或magento2.0中的产品ID获取产品信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在magento2中按产品ID获取所有产品详细信息?我想在首页上显示带有图像的单个产品详细信息.任何帮助将不胜感激.

How to get all product details by product id in magento2? I want to display a single product detail with the image on the homepage. Any help would be appreciated.

推荐答案

尝试以下代码.可能会对您有帮助.

Try below code. It may help you.

<?php 
   $productId = 10;
   $objectManager =  \Magento\Framework\App\ObjectManager::getInstance();
   $currentproduct = $objectManager->create('Magento\Catalog\Model\Product')->load($productId);
?>

这篇关于如何从magento2或magento2.0中的产品ID获取产品信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆