Jump to content

How can I list products in custom module's view?


Recommended Posts

I'm using prestashop 1.7 and I need to display a list of products of one given category in my custom module's front template.

Currently I get the

$products

 like this in the display controller of my module:

    public function initContent()
        {
            parent::initContent();
            $products = Product::getProducts(Context::getContext()->language->id, 0, NULL, 'id_product', 'ASC', 3);
            $products_all = Product::getProductsProperties($this->context->language->id, $products);
            $this->context->smarty->assign(array(
                'products' => $products_all
            ));
            $this->context->smarty->assign('products', $products_all);
            $this->setTemplate('module:goodies/views/templates/front/display.tpl');
        }

In the view I copied the content of the product miniature tpl file.

But I get this exception:

Quote

ContextErrorException Notice: Undefined index: cover

I have correctly uploaded a cover for the product and got one product when displaying my products array with print_r.

As I said I never modified the tpl listing product part.

What am I missing here ?

Thanks for your time.

Link to comment
Share on other sites

  • lolilol4242 changed the title to How can I list products in custom module's view?

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...