Skip to main content
deleted 559 characters in body
Source Link
S.P
  • 1.6k
  • 12
  • 16

Getmagento does not store product id from your quote objectcategory name where user added it.

$cart = Mage::getSingleton('checkout/session')->getQuote();

or You need to do customise it.

$cart = Mage::getModel('checkout/cart')->getQuote();

And load productsFor it you need to create custom column in order_item and quote_item table and with observer (itemscheckout_cart_product_add_before) need to save current category name.

foreach ($cart->getAllVisibleItems() as $item) 
{ 
  $productId = $item->getProduct()->getEntityId();
  $product = Mage::getModel('catalog/product')->load($productId);
  $cats = $product->getCategoryIds();
  foreach($cats as $catid)
  {
  

     $_category = Mage::getModel('catalog/category')->load($categoryId); 

echo $categoryName = $_category->getName();  

  }
}

Get Categories from product id.Current category

$product$category = Mage::getModel('catalog/product')->load($productId);
$cats = $product->getCategoryIdsregistry('current_category');
foreach($cats as $cat)
{
$_category =$categoryid Mage::getModel('catalog/category')=$category->load>getId($cat); 

echo $categoryName = $_category->getName();

}

Get product id from your quote object.

$cart = Mage::getSingleton('checkout/session')->getQuote();

or

$cart = Mage::getModel('checkout/cart')->getQuote();

And load products (items)

foreach ($cart->getAllVisibleItems() as $item) 
{ 
  $productId = $item->getProduct()->getEntityId();
  $product = Mage::getModel('catalog/product')->load($productId);
  $cats = $product->getCategoryIds();
  foreach($cats as $catid)
  {
  

     $_category = Mage::getModel('catalog/category')->load($categoryId); 

echo $categoryName = $_category->getName();  

  }
}

Get Categories from product id.

$product = Mage::getModel('catalog/product')->load($productId);
$cats = $product->getCategoryIds();
foreach($cats as $cat)
{
$_category = Mage::getModel('catalog/category')->load($cat); 

echo $categoryName = $_category->getName();

}

magento does not store product category name where user added it. You need to do customise it.

For it you need to create custom column in order_item and quote_item table and with observer (checkout_cart_product_add_before) need to save current category name.

Current category

$category = Mage::registry('current_category');
$categoryid =$category->getId();
added 358 characters in body
Source Link
S.P
  • 1.6k
  • 12
  • 16

Get product id from your quote object.

$cart = Mage::getSingleton('checkout/session')->getQuote();

or

$cart = Mage::getModel('checkout/cart')->getQuote();

And load products (items)

foreach ($cart->getAllVisibleItems() as $item) 
{ 
  $productId = $item->getProduct()->getEntityId();
  $product = Mage::getModel('catalog/product')->load($productId);
  $cats = $product->getCategoryIds();
  foreach($cats as $catid)
  {
  

     $_category = Mage::getModel('catalog/category')->load($categoryId); 

echo $categoryName = $_category->getName();  

  }
}

Get Categories from product id.

$product = Mage::getModel('catalog/product')->load($productId);
$cats = $product->getCategoryIds();
foreach($cats as $cat)
{
$_category = Mage::getModel('catalog/category')->load($cat); 

echo $categoryName = $_category->getName();

}

Get product id from your quote object.

$cart = Mage::getSingleton('checkout/session')->getQuote();

or

$cart = Mage::getModel('checkout/cart')->getQuote();

And load products (items)

foreach ($cart->getAllVisibleItems() as $item) 
{ 
  $productId = $item->getProduct()->getEntityId();
  $product = Mage::getModel('catalog/product')->load($productId);
  $cats = $product->getCategoryIds();
}

Get Categories from product id.

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

Get product id from your quote object.

$cart = Mage::getSingleton('checkout/session')->getQuote();

or

$cart = Mage::getModel('checkout/cart')->getQuote();

And load products (items)

foreach ($cart->getAllVisibleItems() as $item) 
{ 
  $productId = $item->getProduct()->getEntityId();
  $product = Mage::getModel('catalog/product')->load($productId);
  $cats = $product->getCategoryIds();
  foreach($cats as $catid)
  {
  

     $_category = Mage::getModel('catalog/category')->load($categoryId); 

echo $categoryName = $_category->getName();  

  }
}

Get Categories from product id.

$product = Mage::getModel('catalog/product')->load($productId);
$cats = $product->getCategoryIds();
foreach($cats as $cat)
{
$_category = Mage::getModel('catalog/category')->load($cat); 

echo $categoryName = $_category->getName();

}
Source Link
S.P
  • 1.6k
  • 12
  • 16

Get product id from your quote object.

$cart = Mage::getSingleton('checkout/session')->getQuote();

or

$cart = Mage::getModel('checkout/cart')->getQuote();

And load products (items)

foreach ($cart->getAllVisibleItems() as $item) 
{ 
  $productId = $item->getProduct()->getEntityId();
  $product = Mage::getModel('catalog/product')->load($productId);
  $cats = $product->getCategoryIds();
}

Get Categories from product id.

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