<p>I've found that it was not the best way to to it.<br>
I used the following code and it cleared my problem.</p>

<pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Category);
$criteria-&gt;group = 'productEnvironment';
$entries = $criteria-&gt;find();

foreach ($entries as $entry) {
    echo $entry-&gt;title . '&lt;br&gt;';
    echo $entry-&gt;mountingPreview[0] . '&lt;br&gt;'; // Dirty get the first assets
}
</code></pre>

<p>Hope this helps someone</p>

CC BY-SA 3.0
2015-03-09T17:40:26.993Z
2015-03-09T17:40:26.993Z
Nicolas Binet
<p>When I get a CategoryGroup with the following  </p>

<pre><code>$category = craft()-&gt;categories-&gt;getGroupByHandle('productEnvironment');
</code></pre>

<p>I Just can't figure out how to get the categories inside this category.<br>
Is-there any kind of relation/method ?</p>

<p>Thanks</p>

<p>Nicolas</p>

<categories>
Get all categories from a CategoryGroupModel through API
# Get all categories from a CategoryGroupModel through API

(Asked by: username_0 on 2015-03-09)

When I get a CategoryGroup with the following  
$category = craft()->categories->getGroupByHandle('productEnvironment');

I Just can't figure out how to get the categories inside this category.
Is-there any kind of relation/method ?
Thanks
Nicolas

**Tags:** categories

---

## 1 answers

### Answer by username_0 on 2015-03-09. Score: 1 | Accepted answer

I've found that it was not the best way to to it.
I used the following code and it cleared my problem.
$criteria = craft()->elements->getCriteria(ElementType::Category);
$criteria->group = 'productEnvironment';
$entries = $criteria->find();

foreach ($entries as $entry) {
    echo $entry->title . '';
    echo $entry->mountingPreview[0] . ''; // Dirty get the first assets
}

Hope this helps someone


---

