<p>If you want to use ElementCriteria in your controller, this is how to go about it:</p>

<pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
$criteria-&gt;section('products');
$criteria-&gt;limit = 9;

$products = $criteria-&gt;find();
</code></pre>

<p>Read <a href="http://buildwithcraft.com/docs/plugins/working-with-elements" rel="nofollow">this page</a> for more info on the subject.</p>

CC BY-SA 3.0
2015-06-30T07:16:11.340Z
2015-06-30T07:16:11.340Z
Paul
<p>I am new in Craft CMS and this is my first plugin. Below is my code to get products.</p>

<pre><code>{% craft.entries.section('products').limit(9) %}
</code></pre>

<p>This code is working fine but can I use this code in my controller for getting products?</p>

<p>Thanks</p>

<plugin-development><controller>
can i used craft.entries.section into my Controller
# can i used craft.entries.section into my Controller

(Asked by: username_0 on 2015-06-30)

I am new in Craft CMS and this is my first plugin. Below is my code to get products.
{% craft.entries.section('products').limit(9) %}

This code is working fine but can I use this code in my controller for getting products?
Thanks

**Tags:** plugin-development, controller


---

## 1 answers

### Answer by username_1 on 2015-06-30. Score: 4 | Accepted answer

If you want to use ElementCriteria in your controller, this is how to go about it:
$criteria = craft()->elements->getCriteria(ElementType::Entry);
$criteria->section('products');
$criteria->limit = 9;

$products = $criteria->find();

Read this page for more info on the subject.


---

