title: Magento 1 - get category ID from product ID
body: <p>In magento how to get the category id of each product from its product ID.</p>
  
  <pre><code>   $items    = $request-&gt;getAllItems();
      $c           = count($items); 
  
      for ($i = 0; $i &lt; $c; $i++) {
          if ($items[$i]-&gt;getProduct() instanceof Mage_Catalog_Model_Product) {
  
              if ($items[$i]-&gt;getProduct()-&gt;getId()) {
                 $this-&gt;_dhlAllowed    = false;
                }
          }
      }
  </code></pre>
  
  <p>Here <code>$items[$i]-&gt;getProduct()-&gt;getId()</code> returns product ID. I want its category ID.</p>