获取magento中的产品ID和产品类型? [英] Get product id and product type in magento?

查看:113
本文介绍了获取magento中的产品ID和产品类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立的magento存储.我是magento的初学者.我想在我的phtml文件中获取产品ID和产品输入类型,这可能吗?请指导我..

I am creating magento store. I am beginner in magento. I want to get product id and product input type in my phtml file is this possible? please guide me..

我想通过这种方式来获得产品类型.但它对我不起作用

I am trying to this way to get product type. but its not working for me

$product=Mage::getModel('catalog/product')->load($product_id);
$productType=$product->getTypeID(); 

请指导我...

推荐答案

尝试以下代码以获取当前加载的产品ID:

Try below code to get currently loaded product id:

$product_id = $this->getProduct()->getId();

如果您无权访问$ this,则可以使用Magento注册表:

When you don’t have access to $this, you can use Magento registry:

$product_id = Mage::registry('current_product')->getId();

也为产物I型认为

Also for product type i think

$product = Mage::getModel('catalog/product')->load($product_id); 

$productType = $product->getTypeId();

这篇关于获取magento中的产品ID和产品类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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