Jump to content

Forcing HTTPS on product links in product-list.tpl


maryb66

Recommended Posts

I'm using Prestashop v1.5.4 (yes I know it's an old version I can't upgrade) and changing from http to https everywhere.

 

My .htaccess rewrite is working fine.

Images are loading with https fine.

Menus are all using https the links to other pages

 

Except the product list (product-list.tpl) page is listing the links to the product pages with http not https

So <a href="{$product.link|escape:'htmlall':'UTF-8'}"> is giving me http not https

Where ever there's a link to a product page it's http not https

 

Also in module Product Also Buy the $productLink gives me http not https

 

xml sitemap is also saying http on the product pages

 

Any tips how to fix

Thanks

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

  • 11 months later...

Hi

 

Yes, i activate the ssl on all pages.

The problem is that some pictures of modules homefeature, blockbestseller and "Nouveaux produits" on the Homepage are not in https url. They have "http"

 

The code in product.tpl :

<img class="replace-2x img-responsive" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')|escape:'html':'UTF-8'}" alt="{if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if}" title="{if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} itemprop="image" />

 

I don't know where can i add a "https" in the img url.

 

Thanks

Link to comment
Share on other sites

Hi

 

Yes, i activate the ssl on all pages.

The problem is that some pictures of modules homefeature, blockbestseller and "Nouveaux produits" on the Homepage are not in https url. They have "http"

 

The code in product.tpl :

<img class="replace-2x img-responsive" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')|escape:'html':'UTF-8'}" alt="{if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if}" title="{if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} itemprop="image" />

 

I don't know where can i add a "https" in the img url.

 

Thanks

What version of Prestashop are you using? (that will determine how you fix this issue)

 

Are you using the default theme included with Prestashop, or a custom theme?

 

If a custom theme, then you should contact your theme provider for support.

Link to comment
Share on other sites

I have this thème prestashop :  default-bootstrap version 1.0   

 

Et la version de PS est la 1.6.1.11

 

J'ai trouvé déjà une piste dans le fichier ajax_img.php d'un module.

 
 
Mais il reste encore quelques erreurs que je dois trouver.
insecure script 'http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js'. This request has been blocked; the content must be served over HTTPS.
 

Merrci

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

I notice the exactly same error a week ago on our site. PS 1.6.15 Shoply theme.

 

​For testing purpose I replaced /theme/shoply/product.tpl, /theme/shoply/js/the product js and /controllers/product controller with Prestas' original. The problem remained?! This is really critical and needs a fix.

​a quick fix could be to set SSL only for the cart pages etc., so the "mixed content" warning would go away and page might be a bit faster loading. BUT I do not know if this could trigger issues with htacces since we got a dozen rewrites in it or with GoogleSearchConsole and 404er errors or so :(

Edited by Heinrich.M (see edit history)
Link to comment
Share on other sites

Heinrich, I cannot confirm this behavior. Not for 1.6.1.13 and also not for 1.6.1.15. I would guess your problem is caused by your theme.

A workaround would be to fix by .htacess with the following rules before the prestashop stuff starts:

#### SCULLYS REDIRECT EVERYTHING TO SSL! ####
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301]
#### DONE! ####

And by the way: The product links are generated by ../classes/Link.php and there within function getProductLink. At around line 5 or 6 within this function you see

        $url = $this->getBaseLink($id_shop, null, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop);

which is a call to getBaseLink, in there you should see this code....

        if ($ssl === null) {
            if ($force_ssl === null) {
                $force_ssl = (Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE'));
            }
            $ssl = $force_ssl;
        }
...
        if ($relative_protocol) {
            $base = '//'.($ssl && $this->ssl_enable ? $shop->domain_ssl : $shop->domain);
        } else {
            $base = (($ssl && $this->ssl_enable) ? 'https://'.$shop->domain_ssl : 'http://'.$shop->domain);
        }


Which is forcing the SSL protocol.

  • Like 2
Link to comment
Share on other sites

I don't find the bug

A find just a line in this file :

www\shop\cache\cachefs\d09e877cb9c0e4c7797a7d9c2ceeb260:
    5: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>";s:7:"id_lang";s:1:"2";s:8:"id_store";s:1:"1";}
 
I change http in https, but ii doesn't work.
 
the site is macktenfashion_com
 
Thanks
Link to comment
Share on other sites

<Hello

 

Yes, i change the https in the cache file.

There is always a mixed content with the js file, but it may figure that the site is now on https... cool, but i don't understand

Do you see a securised site  : macktenfashion'dot'com   ?

 

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