Jump to content

Display products in a category Prestashop 1.6


thecolmix

Recommended Posts

Hello

I am working on a module which should allow displaying the products of a category. but i have this error

Notice: Undefined index: products in C:\xampp\htdocs\ldfmega\tools\smarty\sysplugins\smarty_internal_templatebase.php(171) : eval()'d code on line 89

Notice: Trying to get property of non-object in C:\xampp\htdocs\ldfmega\tools\smarty\sysplugins\smarty_internal_templatebase.php(171) : eval()'d code on line 89

Page php

public function ProductCat()
            {
                    $category = new Category(3);
                    // Retrieves the first 15 products of a category
                    $products = $category->getProducts($this->context->language->id, 1, 15);

            } 

Page tpl

<div>{include file="$tpl_dir./product-list.tpl" products=$products }</div>

 

Link to comment
Share on other sites

You lack something:  $this->smarty->assign(array('product' => $product));

public function ProductCat()
{
        $category = new Category(3);
        // Retrieves the first 15 products of a category
        $products = $category->getProducts($this->context->language->id, 1, 15);

        
        $this->smarty->assign(array('product' => $product));

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...