Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

Best Practice for a Product’s Category at Checkout
Jr. Member
Total Posts:  14
Joined:  2008-09-08

I’m wondering if there’s anything the community would consider as a best practice for pulling a single category to tie a product to at the time of checkout.  I’ve read the option here, but I didn’t really like the “unknown” option. Plus, in my initial testing, iterating over $product->getCategoryCollection() didn’t seem to work.

Just to be clear, here’s what I’m doing and where I’m hitting a wall:

* event observer on “sales_order_place_after”
* basically:

$event $observer->getEvent();
$order $event->getOrder();
        foreach (
$order->getAllItems() as $item){
$category Mage::getModel('catalog/category')->load($product->getCategoryId());
//or this
$cats $product->getCategoryCollection();
$i 0;
$cats as $cat){
if ($i==0){

Really the only reasonable solutions I’ve thought up are either just picking the 1st category for a product or dropping category support for magento in in my system completely. The other option (that I really would rather stay away from) is building multiple category stuff into my system.

Anyone have thoughts on this situation?

Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top