Magento (1.9)获取ID';所有产品的s';s类别(在产品页上)

Magento (1.9)获取ID';所有产品的s';s类别(在产品页上),magento,Magento,因此,本周我尝试使用以下代码在产品页面(catalog/product/view.phtml)中获取当前类别的ID,从而成功地破坏了我的站点 $category_id = Mage::registry('current_category')->getId(); 如果您通过通用导航进入产品,这实际上是很好的,但是当您从首页的“特色产品”链接进入产品时,一切都结束了——大概是因为我在不在类别中时要求类别ID 我想知道的是如何获取当前产品所属的所有类别的ID数组 Magento默认目录/产品模

因此,本周我尝试使用以下代码在产品页面(catalog/product/view.phtml)中获取当前类别的ID,从而成功地破坏了我的站点

$category_id = Mage::registry('current_category')->getId();
如果您通过通用导航进入产品,这实际上是很好的,但是当您从首页的“特色产品”链接进入产品时,一切都结束了——大概是因为我在不在类别中时要求类别ID


我想知道的是如何获取当前产品所属的所有类别的ID数组

Magento默认目录/产品模型具有获取产品的所有类别ID的默认方法。 试试看

$product = Mage::getModel('catalog/product')->load($id);
$categoryIds = $product->getCategoryIds();

Magento默认目录/产品模型具有获取产品的所有类别ID的默认方法。 试试看

$product = Mage::getModel('catalog/product')->load($id);
$categoryIds = $product->getCategoryIds();

Magento默认目录/产品模型具有获取产品的所有类别ID的默认方法。 试试看

$product = Mage::getModel('catalog/product')->load($id);
$categoryIds = $product->getCategoryIds();

Magento默认目录/产品模型具有获取产品的所有类别ID的默认方法。 试试看

$product = Mage::getModel('catalog/product')->load($id);
$categoryIds = $product->getCategoryIds();
试试这个:

//This will get the info of current product.

$product = Mage::registry('current_product'); 

$prodID = $product->getId();

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

$categoryIds = $_product->getCategoryIds();

foreach($categoryIds as $categoryIds1) {    
   $_category = Mage::getModel('catalog/category')->load($categoryIds1);

//get all category ID in the current product.

   echo $category_name = $_category->getId();

//get all the Category Name of the Product.

   echo $category_name = $_category->getName();
}
试试这个:

//This will get the info of current product.

$product = Mage::registry('current_product'); 

$prodID = $product->getId();

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

$categoryIds = $_product->getCategoryIds();

foreach($categoryIds as $categoryIds1) {    
   $_category = Mage::getModel('catalog/category')->load($categoryIds1);

//get all category ID in the current product.

   echo $category_name = $_category->getId();

//get all the Category Name of the Product.

   echo $category_name = $_category->getName();
}
试试这个:

//This will get the info of current product.

$product = Mage::registry('current_product'); 

$prodID = $product->getId();

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

$categoryIds = $_product->getCategoryIds();

foreach($categoryIds as $categoryIds1) {    
   $_category = Mage::getModel('catalog/category')->load($categoryIds1);

//get all category ID in the current product.

   echo $category_name = $_category->getId();

//get all the Category Name of the Product.

   echo $category_name = $_category->getName();
}
试试这个:

//This will get the info of current product.

$product = Mage::registry('current_product'); 

$prodID = $product->getId();

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

$categoryIds = $_product->getCategoryIds();

foreach($categoryIds as $categoryIds1) {    
   $_category = Mage::getModel('catalog/category')->load($categoryIds1);

//get all category ID in the current product.

   echo $category_name = $_category->getId();

//get all the Category Name of the Product.

   echo $category_name = $_category->getName();
}