Jump to content

Product getLink not returning correct url


Rawwood

Recommended Posts

Hello there.

 

I'm trying to export some data here.

 

I have a Product object that i call getlink() on. This returns the url to prestashop plus en/1-ipod-nano.html

 

But when i request the url i get a page which says:

 

[Debug] This page has moved

Please use the following URL instead: (prestashop url)/en/music-ipods/1-ipod-nano.html

 

What is wrong?

 

Thank you :)

Link to comment
Share on other sites

this is wrong method.

use "Link" object and function:

/**
	 * Create a link to a product
	 *
	 * @param mixed $product Product object (can be an ID product, but deprecated)
	 * @param string $alias
	 * @param string $category
	 * @param string $ean13
	 * @param int $id_lang
	 * @param int $id_shop (since 1.5.0) ID shop need to be used when we generate a product link for a product in a cart
	 * @param int $ipa ID product attribute
	 * @return string
	 */
	public function getProductLink($product, $alias = null, $category = null, $ean13 = null, $id_lang = null, $id_shop = null, $ipa = 0, $force_routes = false)
Link to comment
Share on other sites

 

this is wrong method.

use "Link" object and function:

/**
	 * Create a link to a product
	 *
	 * @param mixed $product Product object (can be an ID product, but deprecated)
	 * @param string $alias
	 * @param string $category
	 * @param string $ean13
	 * @param int $id_lang
	 * @param int $id_shop (since 1.5.0) ID shop need to be used when we generate a product link for a product in a cart
	 * @param int $ipa ID product attribute
	 * @return string
	 */
	public function getProductLink($product, $alias = null, $category = null, $ean13 = null, $id_lang = null, $id_shop = null, $ipa = 0, $force_routes = false)

 

Okay now i used that function, but i'm still not getting the correct url.

 

This is what i get: prestashop/en/1-ipod-nano.html

 

This is what it redirects to: prestashop/en/music-ipods/1-ipod-nano.html

$p = new Product(1);
$link = new Link();
$url = $link->getProductLink($p);
Link to comment
Share on other sites

  • 3 years later...
On 1/21/2014 at 4:56 PM, vekia said:

so why url isn't correct? it's correct, this is how this function works, you've got url to product page

Hi Vekia,

Rawwood is right. I am facing same issue in PS-1.7.2.2.

My product link url is:

https://unshy.dev-applications.net/home/8-54-paypal-fee.html

When i try to get product url using below code it looks different.

$product = $this->context->controller->getProduct();
$proLink = this->context->link->getProductLink($product);

I get below url:

https://unshy.dev-applications.net/home/8-paypal-fee.html

Default ps_sharebutton module also have this issue.

You can check by clicking any share button from product page.

Can you please help us to resolve this issue.

 

Thanks in advance,

Link to comment
Share on other sites

  • 1 year later...
On 11/7/2017 at 11:30 AM, chirag_0110 said:

Hi Vekia,

Rawwood is right. I am facing same issue in PS-1.7.2.2.

My product link url is:


https://unshy.dev-applications.net/home/8-54-paypal-fee.html

When i try to get product url using below code it looks different.


$product = $this->context->controller->getProduct();
$proLink = this->context->link->getProductLink($product);

I get below url:


https://unshy.dev-applications.net/home/8-paypal-fee.html

Default ps_sharebutton module also have this issue.

You can check by clicking any share button from product page.

Can you please help us to resolve this issue.

 

Thanks in advance,

Hi..
same problem here can you have solved your problem ?
Thanks

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