Jump to content

Display products on custom page using ID


Med Aziz
 Share

Recommended Posts

Hello everyone,

I've been looking for this for quite sometime but i can't seem to find the correct way to display certain products using their ID on custom prestashop page and in page.tpl

I'll be grateful if anyone could help me

Thank you've 

 

Share this post


Link to post
Share on other sites

53 minutes ago, Ress said:

If you need to put on a cms page, you can use this module. If you want to put on another page, you can be inspired from here to do the same for the page where you need it.

https://mypresta.eu/modules/front-office-features/products-on-cms-pages.html

Thanks for your reply.

Actually, I've tested this module but you can't use it in page.tpl.

however, if it's possible i don't wanna use any module to display the specific products.

thanks again 

Share this post


Link to post
Share on other sites

15 hours ago, Ress said:

It's too general when you say you use it in page.tpl. Which page (controller) exactly do you want to use?

i'm using javascript so i'm writing my code in themes\myTheme\templates\cms\page.tpl 

Share this post


Link to post
Share on other sites

Can you detail a little more what you want to do exactly? In principle, if you use javascript and have product ids, you can make an ajax to a controller, and bring the product details, after which you can display them on the page.

Share this post


Link to post
Share on other sites

24 minutes ago, Ress said:

Can you detail a little more what you want to do exactly? In principle, if you use javascript and have product ids, you can make an ajax to a controller, and bring the product details, after which you can display them on the page.

Actually i'm writing an algorithm to display some specific products based on the answers of the user , that's why i used javascript.

can you tell please me how to do it with ajax

Thanks

Share this post


Link to post
Share on other sites

You need to do this in a plugin, you have to put the controller in:
ex. your_module/controllers/front/ajax.php

You can see more details here, e.g. what class you need to extend, how to generate the link to the controller, which you should call when you make the ajax request.

https://devdocs.prestashop.com/1.7/modules/concepts/controllers/front-controllers/

You will have to send the product ids through ajax, there if you have the ids, bring the product details, fetch a template, and send the html back and append.

  • Like 1

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More