Important Note

This tutorial assumes you have already created a pull zone AND enabled shared ssl for that zone.
This CDN implementation pushes only product images to CDN without css, js and other files NOT being part of products.

The Process

  1. Create a backup of file “/classes/Link.php” or copy it to a file called “/classes/Link.php.bckp”
  2. Open file “/classes/Link.php”
  3. Find the following lines:
    public function getCatImageLink($name, $id_category, $type = null) 
        { 
        $uri_path = ($this->allow == 1) ? (__PS_BASE_URI__.'c/'.$id_category.($type ? '-'.$type : '').'/'.$name.'.jpg') : (_THEME_CAT_DIR_.$id_category.($type ? '-'.$type : '').'.jpg'); 
        return $this->protocol_content.Tools::getMediaServer($uri_path).$uri_path; 
        }
  4. Replace these lines with following:
    public function getCatImageLink($name, $id_category, $type = null) 
          { 
          $uri_path = ($this->allow == 1) ? (__PS_BASE_URI__.'c/'.$id_category.($type ? '-'.$type : '').'/'.$name.'.jpg') : (_THEME_CAT_DIR_.$id_category.($type ? '-'.$type : '').'.jpg'); 
          if ($_SERVER['HTTPS'] != 'on') 
          { 
          return str_replace("origindomain.com","foo.bar.netdna-cdn.com",$this->protocol_content.Tools::getMediaServer($uri_path).$uri_path);
          } 
          else 
          { 
          return str_replace("origindomain.com","foo-bar.netdna-ssl.com",$this->protocol_content.Tools::getMediaServer($uri_path).$uri_path); 
          } 
          }

    Important Note:

    origin.domain.com should be replaced by your actual origin domain (plainly without http://) and foo.bar.netdna-cdn.com should be replaced with your own cdn url (temp cdn url also without http://) and shared ssl url foo-bar.netdna-ssl.com replace with your own (without https://).

  5. Find the following lines:
    else 
          $uri_path = _THEME_PROD_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').$theme.'.jpg'; 
          } 
          return $this->protocol_content.Tools::getMediaServer($uri_path).$uri_path;
          }
  6. Replace these lines with following:
    else 
          $uri_path = _THEME_PROD_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').$theme.'.jpg'; 
          } 
          if ($_SERVER['HTTPS'] != 'on') 
          { 
          return str_replace("origindomain.com","foo.bar.netdna-cdn.com",$this->protocol_content.Tools::getMediaServer($uri_path).$uri_path);
          } 
          else 
          { 
          return str_replace("origindomain.com","foo-bar.netdna-ssl.com",$this->protocol_content.Tools::getMediaServer($uri_path).$uri_path); 
          } 
          }

    Important Note

    origin.domain.com should be replaced by your actual origin domain (plainly without http://) and foo.bar.netdna-cdn.com should be replaced with your own cdn url (temp cdn url also without http://) and shared ssl url foo-bar.netdna-ssl.com replace with your own (without https://).

  7. You can check if your PrestaShop is using CDN by loading it in browser and view the source code of the page (CTRL + U).
  8. Restoration to a state without CDN implemented is done simply by copying file “/classes/Link.php.bckp” back to “/classes/Link.php”.