title: How do I get categories for a product in Magento
body: <p>I'm trying to add product_type to my Magento Google Base output based on the product's categories, but I seem to be unable to. I have the following code:</p>
  
  <pre><code>// Get categories from  product to include as product_type
  $categoryIds = $object-&gt;getCategoryIds();
  foreach($categoryIds as $categoryId) {
      $category = Mage::getModel('catalog/category')-&gt;load($categoryId);
      $this-&gt;_setAttribute('product_type', $category-&gt;getName(), 'text' );
  }
  </code></pre>
  
  <p>The issue is that it returns <em>all</em> of the categories, not just the ones the product is in. Anyone have a solution?</p>