如何在magento中获取父产品ID? [英] How to get parent product id in magento?

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

问题描述

我知道在Magento 1.4.2.0中,这样获得父级ID

I know that in Magento 1.4.2.0 one gets parent id's like so

list( $parentId ) = Mage::getModel('catalog/product_type_configurable')
                            ->getParentIdsByChild( $product->getId() );

我的问题是:如果我不知道父母是谁,我如何知道使用'catalog/product_type_ 可配置'与'catalog/product_type_ 分组 >用于获取ID的模型?

My question is: if I don't know what the parent is, how do I know to use the 'catalog/product_type_configurable' vs 'catalog/product_type_grouped' model to get the id?

推荐答案

您可以使用:

$product->getTypeInstance();

哪个将返回您产品的类型对象

Which will return the type object of your product

然后您可以执行以下操作:

Then you can perform your:

->getParentIdsByChild()

最终放弃:

$product->getTypeInstance()->getParentIdsByChild($child->getId());

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

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