jdgojariya Posted September 7, 2013 Share Posted September 7, 2013 Hello I want to display all product list in my own custom page that is created under my module folder. Thanks Link to comment Share on other sites More sharing options...
vekia Posted September 7, 2013 Share Posted September 7, 2013 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 1 Link to comment Share on other sites More sharing options...
jdgojariya Posted September 7, 2013 Author Share Posted September 7, 2013 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 More sharing options...
vekia Posted September 7, 2013 Share Posted September 7, 2013 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. 1 Link to comment Share on other sites More sharing options...
jdgojariya Posted September 11, 2013 Author Share Posted September 11, 2013 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 More sharing options...
p414 Posted February 7, 2014 Share Posted February 7, 2014 vekia I have a problem when I try use this function... can u help me????tell me what files I need to put that function??? and from where I can call it? thanks Link to comment Share on other sites More sharing options...
vekia Posted February 8, 2014 Share Posted February 8, 2014 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 More sharing options...
p414 Posted February 12, 2014 Share Posted February 12, 2014 ok, then I need put this code on my init function of my module... ... I will do and I happened to notice this thanks!!! Link to comment Share on other sites More sharing options...
datshay Posted August 11, 2015 Share Posted August 11, 2015 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now