Jump to content

How to add additional parameters in product link


vinay123

Recommended Posts

Hello,

 

I have enable friendly url in my prestashop admin.

I created a module slide show module in which i use the following code to generate the link to the product page :

 

 

$obj = new product($product_id);

$page_link = $obj->getLink();

 

which generates the link as such :

 

http://localhost/dem...als-on-mp3.html

 

My question is how can i add an extra parameter in the url

 

example

 

http://localhost/demo/en/EXTRAPARAMETER/14-deals-on-mp3.html

 

and being able to retrieve the extra parameter via : Tool::getValue in on my productController page.

 

Thank you

Link to comment
Share on other sites

Hello,

 

To get your parameter with Tool::getValue, means that your parameters have been url rewritten.

Then yes the way you want it, ask you to modify rewrite engine along prestashop. :ph34r: Now I am scared.

 

What is the final purpose of your parameters, there is perhaps a simplier and safer way to get the behaviour you want.

 

Have a nice day.

Link to comment
Share on other sites

  • 3 months later...

I think i have the same problem...

 

I need to difference between models of the same product....

I used combinations for this, so I got my product, and a list of models ( made like combinations.... )

 

The problem arrives with the list function... I can only change the image of the product... on mouse over...

but I dont have any functionality that let me select one model... to send it to the shopcart...

I always send the first model...

 

so I started to change the product logic so I can send models to the url... so product controller can difference between different models of the same product... so the shopcart can do it too...

 

I dont know if I explain myself....

But I see sending another parameter to the url as a solution...

 

maybe I can use a data estructure to save the selection of the model... and use this data always i need to create a linkt with this product... but we loose the firendly-url information with this solution....

Link to comment
Share on other sites

  • 3 years later...

Hello, very old post, but i managed to solve it. 

To add parameter to link in product list I use : 

{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category, $product.ean13, null, null, $product.id_product_attribute)} Product-list.tpl

But first, you have to add product attribute, to product. Where all products are  assigned.

And append add to cart button &id_product_attribute={$product.id_product_attribute} on same tpl. Hope this solves someone problem

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

I just want to say that I achieved what i want with this code 

$link->getProductLink($product.id, $product.link_rewrite, null, null, null, null, <<<<your product id attribute >>>>, false ,false, true)

just change <<<<your product id attribute >>>> to yours id_product_attribute and that's all. 

Edited by hakeryk2 (see edit history)
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...