Category: troubleshoot

  • Prestashop: Stop subdomains from keep redirecting to main domain

    Source: https://www.prestashop.com/forums/topic/635858-2nd-store-redirects-to-main-store-multistore-redirection-problem/?tab=comments#comment-2634035

    After installing prestashop, created subdomains don’t work properly due to the .htaccess rewrite conditions automatically created by prestashop.

    Add the following right at the end to solve this issue

    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

    //////////////////

    some additional ones to try in case doesn’t work

    Source: https://www.prestashop.com/forums/topic/635858-2nd-store-redirects-to-main-store-multistore-redirection-problem/?tab=comments#comment-3116242

    #First condition, If is HTTPS without wwww, redirects to www.
    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

    #Second condition, If is not HTTPS and without www, redirects to HTTPS with WWW.
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*) https://www.%{SERVER_NAME}/$1 [R,L]

    #Third, If is not HTTPS and have www, redirects only to HTTPS
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} ^www\.
    RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]

  • Prestashop: Full-width for CMS pages

    Warehouse theme.

    If the display left column option is disabled in the advanced setting of the theme, the center column does not know it is supposed to be in full width. A blank space is shown on the left.

    Enable “display left column”, then click “x” for all modules you don’t want to appear in the left column. E.g. CMS. After that, clear cache and reload. Full-width center column now works.

  • WordPress: Disable plugins from database for troubleshooting

    Source: https://www.templatemonster.com/help/wordpress-disable-plugins-via-database-manual-removal.html
    UPDATE wp_options SET option_value = ” WHERE option_name = ‘active_plugins’;

  • Prestashop: delete customer’s cookies

    Solution: https://www.prestashop.com/forums/topic/364875-how-to-delete-cookies-customers/?tab=comments#comment-2348354

    Overriding the method __construct (classes/Cookie.php) changing the commented lines

    override/classes/Cookie.php

    class Cookie extends CookieCore
    {
        public function __construct($name, $path = '', $expire = null, $shared_urls = null, $standalone = false, $secure = false)
        {
            $this->_content = array();
            $this->_standalone = $standalone;
            $this->_expire = is_null($expire) ? time() + 1728000 : (int)$expire;
            $this->_path = trim(($this->_standalone ? '' : Context::getContext()->shop->physical_uri).$path, '/\\').'/';
            if ($this->_path{0} != '/') {
                $this->_path = '/'.$this->_path;
            }
            $this->_path = rawurlencode($this->_path);
            $this->_path = str_replace('%2F', '/', $this->_path);
            $this->_path = str_replace('%7E', '~', $this->_path);
            $this->_domain = $this->getDomain($shared_urls);
    
            //remove www from url > example: .domain.com
            $this->_domain =str_replace('www','', $this->_domain);
    
            //Change cookie name "PrestaShop" > "MyCookieName" This will make all your customers cookies obsolete.
            $this->_name = 'MyCookieName-'.md5(($this->_standalone ? '' : _PS_VERSION_).$name.$this->_domain);
    
            $this->_allow_writing = true;
            $this->_salt = $this->_standalone ? str_pad('', 8, md5('ps'.__FILE__)) : _COOKIE_IV_;
            if ($this->_standalone) {
                $this->_cipherTool = new Blowfish(str_pad('', 56, md5('ps'.__FILE__)), str_pad('', 56, md5('iv'.__FILE__)));
            } elseif (!Configuration::get('PS_CIPHER_ALGORITHM') || !defined('_RIJNDAEL_KEY_')) {
                $this->_cipherTool = new Blowfish(_COOKIE_KEY_, _COOKIE_IV_);
            } else {
                $this->_cipherTool = new Rijndael(_RIJNDAEL_KEY_, _RIJNDAEL_IV_);
            }
            $this->_secure = (bool)$secure;
    
            $this->update();
        }
    }
  • Prestashop: category pages noindex

    Due to layered navigation block disabling robots by default…

    Solution: https://www.prestashop.com/forums/topic/866411-category-pages-noindex/

    Hi, the problem comes from the “Layered navigation block” module. After the update to v2.2.1 something has changed.

    To Fix the problem for Prestashop 1.6 go to Modules and Services >> Layered navigation block >> Configure
    Scroll down to the CONFIGURATION section and set to YES the “Allow indexing robots….”
    This action will change the metatags for all category pages to “indexed, follow”

  • Prestashop: fake customer registrations spam

    Source: https://www.prestashop.com/forums/topic/981159-securite-spam-customer-account-solution-13-15/

    within your class classes/Validate.php – either in the native code, or into an override, add this function

        public static function isCustomerName($name)
        {
            if (preg_match(Tools::cleanNonUnicodeSupport('/www|http/ui'),$name))
               return false;
    
            return preg_match(Tools::cleanNonUnicodeSupport('/^[^0-9!\[\]<>,;?=+()@#"°{}_$%:\/\\\*\^]*$/u'), $name);
        }

    Then modify inside classes/Customer.php

                'lastname' =>                    array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
                'firstname' =>                    array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),

    by

                'lastname' =>                    array('type' => self::TYPE_STRING, 'validate' => 'isCustomerName', 'required' => true, 'size' => 32),
                'firstname' =>                    array('type' => self::TYPE_STRING, 'validate' => 'isCustomerName', 'required' => true, 'size' => 32),
  • Acrobat X Pro: PDF Flattener Preview bug workaround

    Tried to outline fonts inside Illustrator and the PDF exported shows random distortions like wider Ls here and there. If we export the file as a PDF with the fonts as is, there are no issues.

    However, have encountered printers who have problems viewing common fonts. So it is a must to ensure fonts are outlined.

    Solution: use PDF Flattener within Acrobat X Pro.

    BUT there is a bug.

    If the fonts used are not “perfect”, the Flattener Preview is unable to outline the fonts.

    See solution: https://www.youtube.com/watch?v=U5umF_kTcaA

    As a workaround, inside Acrobat
    1) Go to Tools (top right corner) > Pages > Add a watermark like a ‘full stop’ to the PDF. Size it down small. Choose 0% Opacity. Click OK.

    2) Add the Print Production menu to Tools if it is not enabled by default. Click on the tiny menu list icon under Tools (right)

    3) Go to Print Production > Flattener Preview and Tick Convert all text to outlines and convert all strokes to outlines. Then apply to all pages in the document and SAVE the PDF.

    4) Final check, view file properties to see if all the fonts are removed.

    Joy 🙂

  • Prestashop: Fix layered navigation block doesn’t keep order position of filters

    Solution: https://www.prestashop.com/forums/topic/317265-layered-navigation-block-dont-keep-order-position/?do=findComment&comment=2128180
    https://github.com/musicpanda/blocklayered/commit/c53257c6cefcf5551d1f3cd51268fde658c1ad6b?diff=unified
    Info: It repairs one file: blocklayered_admin.js in the module
    /modules/blocklayered/blocklayered_admin.js

    If you’re using other themes look for the corresponding file to make the change
    e.g. warehouse theme
    /modules/blocklayered_mod/blocklayered_mod_admin.js
    look for

    if (typeof filters !== 'undefined')
    {
    filters = JSON.parse(filters);
    var filtertmp = []; //filter sort fix
    var filteri = 0; //filter sort fix
    console.log(filters);

    for (filter in filters)
    {
    $('#'+filter).attr("checked","checked");
    $('#selected_filters').html(parseInt($('#selected_filters').html())+1);
    $('select[name="'+filter+'_filter_type"]').val(filters[filter].filter_type);
    $('select[name="'+filter+'_filter_show_limit"]').val(filters[filter].filter_show_limit);
    //filter sort fix start
    var elt = document.getElementById(filter);
    var eltli = elt.parentNode.parentNode.parentNode; /* the LI */
    var eltul = elt.parentNode.parentNode.parentNode.parentNode; /* the UL */
    filtertmp[filteri++] = eltul.removeChild(eltli);
    }
    for(var i=0; i

  • Prestashop: How to create admin controller to add link of module to backoffice menu

    Troubleshoot: PrestaShop Admin Module Controller Not Found

    https://stackoverflow.com/questions/37984270/prestashop-admin-module-controller-not-found

    Whenever this happened to me was because I hadn’t created a menu entry for my new controller.

    What I’d advise you to do is to go to Administration > Menus then created a new entry.

    Fill in the form like this :

    Name: Productarticle
    Class: AdminProductarticle
    Module: productarticle (if that’s the name you gave your module)
    Active: NO (this way you don’t have to have a menu entry that’s gonna be useless to you)

    On top of that you should have something like this in your __construct()

    E.g. filename modules/module_name/controllers/admin/AdminProductarticleController.php

    class AdminProductarticleController extends ModuleAdminController
    {
    public function __construct()
    {
    $this->module = ‘productarticle’; //refers to your module’s $this->name = ‘productarticle’;
    $this->bootstrap = true;
    //$this->context = Context::getContext(); //not necessary
    //The following 2 lines are useful if you have to link your controller to a certain table for data grids
    $this->table = ‘contribution’;
    $this->className = ‘Contribution’;

    parent::__construct();

    Tools::redirectAdmin(Context::getContext()->link->getAdminLink(‘AdminModules’, true) . ‘&configure=nameofmodule&tab_module=front_office_features&module_name=nameofmodule’);
    }
    }

  • Blacklist Check IP

    Question – https://www.quora.com/How-exactly-does-a-domain-name-email-get-blacklisted-Whats-the-trigger-or-what-is-responsible-for-it

    Check:
    https://www.dnsbl.info/dnsbl-list.php

    Email needs to have rDNS and FCrDNS, so that it is not blacklisted.

    What is rDNS?

    Introduction to rDNS

    What is FCrDNS?

    Introduction to FCrDNS

    Remove from blacklist
    https://www.ndchost.com/wiki/rbl/yahoo

    Query and delist

    Spam check: https://www.spamhaus.org/lookup/

    Domain health check: https://mxtoolbox.com/domain/