Search code examples
oxid

Oxid - Get product categories based on article id


I have an product that is assigned to more than 1 category.

I am interested how can i select all the categories that the product is assigned to based on productID.

something like get Article Categories (id Article)


Solution

  • It's possible to get category ID's by using oxArticle::getCategoryIds(), but you have to have article object loaded like:

    $oArticle = oxNew('oxarticle');
    $oArticle->load('id');
    $aCategories = $oArticle->getCategoryIds();
    

    If you need objects just foreach to load them.