Jump to content

How to remove id_product_attribute from product links?


Kerm

Recommended Posts

12 hours ago, WebDesign-Entreprise said:

Also you can change in templates/catalog/_partials/miniatures all links to main product instead of attributes links.

Change all <a href="{$product.url}" by <a href="{$product.canonical_url}"

Now Google will not see attributes urls.

Which file do you change? I changed product.tpl, but urls didn't change. I would love to have urls without attributes.

Link to comment
Share on other sites

5 hours ago, WebDesign-Entreprise said:

Hello,
Yes it is in YOUR-THEME/templates/catalog/_partials/miniatures/product.tpl

You have link on the image, and the title. Try also to recompile files in smarty. Preferences > Performances > Recompile files

Olivier

Hi,

still no luck. All urls are with attributes. 

Link to comment
Share on other sites

  • 4 weeks later...
On 5/20/2019 at 10:38 AM, WebDesign-Entreprise said:

Hello,

Actually everything is ok because PS17 generates canonical url in the head part. So Google knows that /en/women/2-10-brown-bear-printed-sweater.html#/2-size-m is just another page of /en/women/2-brown-bear-printed-sweater.html

You can see more infos here: https://support.google.com/webmasters/answer/139066?hl=en

The bad thing is that canonical url (/en/women/2-brown-bear-printed-sweater.html) is redirected with 301 or 302 code to default attribute product page. This is very bad because you say two differents informations to Google.

The PS1.7.6 will correct this point (https://github.com/PrestaShop/PrestaShop/pull/13009)

In controllers/front/ProductController.php replace line 55 with:


 public function canonicalRedirection($canonical_url = '')
    {
        if (Validate::isLoadedObject($this->product)) {
            if (!$this->product->hasCombinations() ||
                !$this->isValidCombination(Tools::getValue('id_product_attribute'), $this->product->id)) {
                //Invalid combination we redirect to the canonical url (with attribute id)
                unset($_GET['id_product_attribute']);
            } else {
                //Only redirect to canonical (parent product without combination) when the requested combination is not valid
                //In this case we are in a valid combination url and we must display it with redirection for SEO purpose
                return;
            }
            //Note: we NEED these 6 arguments to have $ipa=null or else a parameter will be added
            //id_product_attribute=0 and force the redirection
            parent::canonicalRedirection($this->context->link->getProductLink(
                $this->product,
                null,
                null,
                null,
                null,
                null,
                null
            ));
        }
    }

I think now the situation is ok.

You can test here: https://www.anakiss.fr/chaussons-en-laine-pour-bebe/11-chaussons-hauts.html

Olivier

I tried it in 1.7.4.4 and it did not work all product pages were blank.  1.7.6 is not available now is there any way you can get this to work in 1.7.4.4?  I've got duplicate pages on all my products.  Thanks for any help you can give.

Edited by need2011 (see edit history)
Link to comment
Share on other sites

I just tried to use the debug after uploading the updated ProductController.php with your code .   After I used the debugger it somehow updated the database with bad paths to all products that had multi colors.  All those products now go to "not found" or another page that has nothing to do with the product.   I am going to have to restore the site as nothing I can do to fix the problem.    When I tried it yesterday without the debugger there was no problem deleting the file and using the original.  I only had problems using the debugger.  There may be a problem with the debugger.  I will not use the debugger again.

Here are the error codes from the debugger this was a product page:

 (1/1) ContextErrorException

Notice: Undefined index: page_name
in ce8afe3a30b7bb01f7c6f72bddd606b951f36b83_2.file.html.tpl.php line 59
at content_5d1a18ded42b11_91927099(object(SmartyDevTemplate))in smarty_template_resource_base.php line 123
at Smarty_Template_Resource_Base->getRenderedTemplateCode(object(SmartyDevTemplate))in smarty_template_compiled.php line 114
at Smarty_Template_Compiled->render(object(SmartyDevTemplate))in smarty_internal_template.php line 216
at Smarty_Internal_Template->render(false, 0)in smarty_internal_templatebase.php line 232
at Smarty_Internal_TemplateBase->_execute(null, null, null, null, 0)in smarty_internal_templatebase.php line 116
at Smarty_Internal_TemplateBase->fetch(null, null, null, null, false, true, false)in SmartyDevTemplate.php line 41
at SmartyDevTemplateCore->fetch()in Module.php line 2244
at ModuleCore->display('/home/absserv1/public_html/ionelectricbicycles.com/modules/htmlbox/htmlbox.php', 'html.tpl')in htmlbox.php line 542
at htmlbox->hookheader(array('cookie' => object(Cookie), 'cart' => object(Cart), 'altern' => 5))in Hook.php line 924
at HookCore::coreCallHook(object(htmlbox), 'hookHeader', array('cookie' => object(Cookie), 'cart' => object(Cart), 'altern' => 5))in Hook.php line 332
at HookCore::callHookOn(object(htmlbox), 'displayHeader', array('cookie' => object(Cookie), 'cart' => object(Cart), 'altern' => 5))in Hook.php line 860
at HookCore::exec('displayHeader')in FrontController.php line 552
at FrontControllerCore->initContent()in PageNotFoundController.php line 42
at PageNotFoundControllerCore->initContent()in Controller.php line 255
at ControllerCore->run()in Dispatcher.php line 428
at DispatcherCore->dispatch()in index.php line 28

Link to comment
Share on other sites

I agree about the debugger, but it messed up my site.  I had to go into the products and redirect them to so that they would work.  I am not that clear on how to make your update work.  I am using PS 1.7.4.4 why wouldn't "page_name"  be defined?    I don't know how to correct that problem?  Thanks for your reply.

Link to comment
Share on other sites

  • 4 weeks later...

PS 1.7.5

Hi

We have a problem related to this which is a pain in the ...

If we have 4 images on a product (these include additional images such as lifestyle, floorplans, etc), and one of each colour on the 3 different combinations we would have 7 images in all (screen 1). The way the flow from category list page works is that there is a default image for each combination, when I click on the product on the category list page to take me to the product page, I will only see the image for that combination and not all of the other 7 images (screen 2). To compound the issue, the link on the product page - "display all pictures" - available upto PS1.6 has been removed in 1.7 (screen 3). This means that I will never be able to see all the images, only the image assigned to each combination. This is a flaw and a backward step IMO. The fact that I cannot remove the "id_product_attribute" from the route-to-products field in "SEO & URLS" is baffling.

If anyone from PS can explain the thinking behind this change it would be appreciated because I cannot see the benefits.

Also, if anyone has a fix or override to get round this flaw I would be very grateful.

Thanks

 

screen1.JPG

screen2.JPG

screen3.JPG

screen4.JPG

Link to comment
Share on other sites

  • 2 weeks later...

Hi prestatent,

yes i think is a backword too...that button was a nice feature in ps 1.6, but hey take a look at this topic, maybe it's a solution. I've never implemented this mod , so i don't know if it works but is worth a try....don't forget to backup the files before modify it!!.

 

Ciao

Link to comment
Share on other sites

On 9/12/2016 at 10:28 PM, Kerm said:
Hello, as i see in new version all product combinations have self page, like:

 

 

 

 

/en/blouses/2-7-blouse.html

 

 

/en/blouses/2-8-blouse.html

 

 

 

 

 

This is very, very bad for seo, this leads to content duplication...one product can have multiple links with same description.

 

Hi there,

Have you found the way to remove 7 & 8 I have the same problem in my PS 1.7.6

Link to comment
Share on other sites

  • 1 month later...

Hey mir-aus..if you want to remove those id's you have to use a Pretty url module...but take care because you can have collateral effects with some modules as Blogs , review modules etc...

Anyway the situation seems to be fixed in 1.7.6.1 and now we have no more canonical redirection to default combination.

In previews shops i modified canonicalRedirection function as suggested by Webdesign user and all is fine:-).....and yes this redirection is a big problem from a SEO point of view so fix it or upgrade to last ps version folks.

Ciao

Link to comment
Share on other sites

  • 6 months later...
  • 4 months later...
On 6/3/2019 at 7:53 AM, WebDesign-Entreprise said:

Hello,
Yes it is in YOUR-THEME/templates/catalog/_partials/miniatures/product.tpl

You have link on the image, and the title. Try also to recompile files in smarty. Preferences > Performances > Recompile files

Olivier

For me that's definetly the solution !!! No more link with declinaison are accessible. Link from category pages and in the canonical of the products pages are sames. 
You only give to search engine the canonical url.
Thank you Olivier for the tip !

Link to comment
Share on other sites

  • 2 months later...
On 6/1/2019 at 10:54 AM, WebDesign-Entreprise said:

Also you can change in templates/catalog/_partials/miniatures all links to main product instead of attributes links.

Change all <a href="{$product.url}" by <a href="{$product.canonical_url}"

Now Google will not see attributes urls.

This worked for me, 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...