我该如何通过产品sku或id获取产品类型(simplee、configurable/grouped等),我已经加载了产品集合,并尝试通过以下方式获取产品类型:
$_product->getTypeId()
但它没有打印产品类型。请帮忙。谢谢。
我该如何通过产品sku或id获取产品类型(simplee、configurable/grouped等),我已经加载了产品集合,并尝试通过以下方式获取产品类型:
$_product->getTypeId()
但它没有打印产品类型。请帮忙。我认为$_product->getTypeId()
应该有效。如果无效,请尝试$_product->getResource()->getTypeId()
我在phtml文件中通过以下方式获取产品类型
$product=Mage::getModel('catalog/product')->load($product_id);
$productType=$product->getTypeID();
//Simple Product
if($productType == 'simple')
{
echo "Simple Product";
}
//Configurable Product
if($productType == 'configurable')
{
echo "Configurable Product";
}
你知道吗?通过执行print_r($_product->getData()),你可以看到一个对象里面的内容。
这里有另一个提示。
如果您正在遍历购物车项目,请使用getProductType()获取产品类型信息。例如 -
foreach( $cartItems as $item ){
if($item->getProductType() == "configurable") {