How to list all products

Discussion in 'Customization & add-ons' started by cebasso, Jun 10, 2015.

  1. cebasso

    cebasso New Member

    Joined:
    Jun 7, 2015
    Messages:
    4
    Hello,

    Well, i need to do something... but i think this way will be more simple...

    How i can list all products with their categories?

    and how to do the same with users including their groups?

    thanks!
  2. cebasso

    cebasso New Member

    Joined:
    Jun 7, 2015
    Messages:
    4
    Just placing here for who need it too...

    Thank you Andrey Yerokhin from aMember Support (email)

    PHP:
    $di Am_Di::getInstance();

    $products $di->productTable->findBy();
    $categories $di->productCategoryTable->getOptions();

    foreach (
    $products as $p) {
      
    $cats $p->getCategories(); //array with id of category
      
    foreach ($cats as $c_id)
         
    $c_title $categories[$c_id]

    }

    $users $di->userTable->findBy();
    $groups $di->userGroupTable->getOptions();
    foreach (
    $users as $u) {
        
    $gs $u->getGroups(); //array of Ids
        
    foreach ($gs as $g_id)
           
    $g_title $groups[$g_id]
    }

Share This Page