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?



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

$criteria = craft()->elements->getCriteria(ElementType::Entry);
$criteria->limit = 9;

$products = $criteria->find();

Read this page for more info on the subject.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.