Jump to content

How to display all product list in my custome page under my module folder


jdgojariya

Recommended Posts

you need to use function category->getProducts(); and then - display products in .tpl file with {foreach} loop on this function

exactly as it is in categoryController

Thank u very much for quick ans/

  I am new in prestashop. I createed basic module structure. And after Installing it only display a static content. Now I want all product list instead of static content. can you explain me how it is possible.

Link to comment
Share on other sites

use function i mentioned, get all products list with function getProducts();

then pass contents of array to smarty variables, and do foreach on it in .tpl file.

 

 

example:


$products = Product::getProducts($this->context->language->id, 0, 100);
$products_all = Product::getProductsProperties($this->context->language->id, $products);
$this->context->smarty->assign(array(
        'products' => $products_all
));

 

then in .tpl file you can do foreach loop on $products variable.

  • Like 1
Link to comment
Share on other sites

use function i mentioned, get all products list with function getProducts();

then pass contents of array to smarty variables, and do foreach on it in .tpl file.

 

 

example:


$products = Product::getProducts($this->context->language->id, 0, 100);
$products_all = Product::getProductsProperties($this->context->language->id, $products);
$this->context->smarty->assign(array(
        'products' => $products_all
));

 

then in .tpl file you can do foreach loop on $products variable.

Thank u so much for quick replay. 

Link to comment
Share on other sites

  • 4 months later...

author of this thread wanted to put all products on his custom page,

so he/she probably has got controller for this.

 

it mean that you have to put this code into your controller core, inside init function where you usually define the smarty template array variables

Link to comment
Share on other sites

  • 1 year later...

use function i mentioned, get all products list with function getProducts();

then pass contents of array to smarty variables, and do foreach on it in .tpl file.

 

 

example:


$products = Product::getProducts($this->context->language->id, 0, 100);
$products_all = Product::getProductsProperties($this->context->language->id, $products);
$this->context->smarty->assign(array(
        'products' => $products_all
));

 

then in .tpl file you can do foreach loop on $products variable.

 

 

Hi Vekia,

 

I did  the same copied the code and applied for each in tpl file. But the  id_image value is always en-default. 

 

The correct image id is not pulled out. So I am not able display the product image. I am on prestasho 1.5.5

 

How can I get the image ?

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