如何在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());