Jump to content

Edit History

ale123

ale123

TL;DR: how can I generate a product link that automatically select an attribute option?

---------------

I think there is a bug somewhere in product link generator.

Let's assume we have a product with 3 options, like sizes: "S, M, L". Their IDs on DB are: 7,8,9

Now I would like to create a direct link to the product, with size "M" selected.

I'm using this very long call: 

$this->context->link->getProductLink((new Product(87), null, null, null, null, null, 8);

were 87 is the ID of the product and "8" is the ID of the attribute "M"

Link is generated properly:

/87-8-my-product.html

But when opened, it does a redirect to the canonical url ignoring the attribute. Probably because the select in the attribute has a progressive ID (1,2,3) based on the option position in the select and not based on the attributes IDs

Any idea ?

ale123

ale123

TL;DR: how can I generate a product link that automatically select an attribute option?

---------------

I think there is a bug somewhere in product link generator.

Let's assume we have a product with 3 options, like sizes: "S, M, L". Their IDs on DB are: 7,8,9

Now I would like to create a direct link to the product, with size "M" selected.

I'm using this very long call: 

$this->context->link->getProductLink((new Product(87), null, null, null, null, null, 8);

were 87 is the ID of the product and "8" is the ID of the attribute "M"

Link is generated properly:

/87-8-my-product.html

But when opened, it does a redirect to the canonical url ignoring the attribute. Probably because the select in the attribute has a progressive ID (1,2,3) based on the option position in the select and not based on the attributes IDs

Any idea ?

×
×
  • Create New...