Tag: prestashop 1.6

  • Prestashop: Warehouse theme mobile menu disable link on category parent

    File edits are uploaded on:
    modules/iqitmegamenu/iqitmegamenu.php
    override/modules/iqitmegamenu/iqitmegamenu.php
    themes/warehouse/js/modules/iqitmegamenu/js/mlpushmenu.js

    1) modules/iqitmegamenu/iqitmegamenu.php
    changed private function generateCategoriesMenu($categories, $depth_limit, $depth = 0) to
    protected function generateCategoriesMenu($categories, $depth_limit, $depth = 0)

    Overrides do not work on private functions. Could have just edited the whole file but did this for future reference.

    2) override/modules/iqitmegamenu/iqitmegamenu.php

    3) themes/warehouse/js/modules/iqitmegamenu/js/mlpushmenu.js
    comment out the script that prepends responsiveInykator to the div
    comment out the script that changes + to –
    leave this as standalone so that the submenu shows when tapped on $(this).parent().children(‘ul’).slideToggle(300);

  • 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 add the invoice number to the backoffice orders grid

    Source: https://www.prestashop.com/forums/topic/300119-solved-how-to-add-the-invoice-number-to-the-orders-grid/?do=findComment&comment=1517949

    Try to start with adding another array item to $this->fields_list

    add code to:
    /controllers/admin/AdminOrdersController.php

    ‘invoice_number’ => array(
    ‘title’ => $this->l(‘Rechnung-Nr: ‘),
    ‘width’ => 50
    ),

  • 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’);
    }
    }

  • Prestashop: Add style number to product page

    Using warehouse theme. When product has combinations, the SKU is shown. I wanted to also show the main product style number for easy reference.
    https://www.prestashop.com/forums/topic/605088-slovedhow-to-show-reference-numbers-on-product-page/?do=findComment&comment=2540332


    {$product->reference|escape:'html':'UTF-8'}

    There are 2 locations to add in ware theme product.tpl

  • Prestashop 1.6: Breadcrumb to display the category that product is currently in (not its default category)

    Update 20190608: Due to SEO concern, the friendly url of product is configured to not show subcategories, i.e. domain.com/product-name-1234.html so the following solution does not work as it uses the subcategories in the friendly url as reference

    Source: https://www.prestashop.com/forums/topic/167513-how-to-show-the-full-breadcrumb-to-the-default-category-on-every-product-page/?do=findComment&comment=2684341

    Function  assignCategory(), preferably in override/controllers/front/ProductController.php

    protected function assignCategory()
    {
    // Assign category to the template
    if ($this->category !== false && Validate::isLoadedObject($this->category) && $this->category->inShop() && $this->category->isAssociatedToShop()) {
    $path = Tools::getPath($this->category->id, $this->product->name, true);
    $all_product_subs = Product::getProductCategoriesFull($this->product->id, $this->context->language->id);

    if(isset($all_product_subs) && count($all_product_subs)>0)
    {
    foreach($all_product_subs as $subcat)
    $all_product_subs_path = array(); //reset array, only last one is used
    $all_product_subs_path[] = Tools::getPath($subcat[‘id_category’], ”, true);
    }

    } elseif (Category::inShopStatic($this->product->id_category_default, $this->context->shop)) {
    $this->category = new Category((int)$this->product->id_category_default, (int)$this->context->language->id);
    if (Validate::isLoadedObject($this->category) && $this->category->active && $this->category->isAssociatedToShop()) {
    $path = Tools::getPath((int)$this->product->id_category_default, $this->product->name);
    }
    }
    if (!isset($path) || !$path) {
    $path = Tools::getPath((int)$this->context->shop->id_category, $this->product->name);
    }

    if (Validate::isLoadedObject($this->category)) {

    // various assignements before Hook::exec
    $this->context->smarty->assign(array(
    ‘path’ => Tools::getPath($this->category->id, ”, true),
    //THIS CONTAINS ALL PRODUCT SUBCATEGORIES PATH
    ‘all_product_subs’=>$all_product_subs_path,
    ‘category’ => $this->category,
    ‘subCategories’ => $this->category->getSubCategories($this->context->language->id, true),
    ‘id_category_current’ => (int)$this->category->id,
    ‘id_category_parent’ => (int)$this->category->id_parent,
    ‘return_category_name’ => Tools::safeOutput($this->category->name)
    ));

    }
    $this->context->smarty->assign(array(‘HOOK_PRODUCT_FOOTER’ => Hook::exec(‘displayFooterProduct’, array(‘product’ => $this->product, ‘category’ => $this->category))));
    }

  • Prestashop: Fix pagination error on Attributes and Features in Backoffice

    https://github.com/PrestaShop/PrestaShop/pull/8638/files

    https://www.prestashop.com/forums/topic/554037-possible-bug-on-product-attributes-list-pagination-in-1616/

    https://www.prestashop.com/forums/topic/507337-backoffice-pagination-error-in-products-attribute-section/

    Hi, i fixed this by adding a short code to ‘AdminAttributesGroupsController.php’ in /controllers/admin/

        public function setRedirectAfter($url)
        {
            $addUrl = '';
            if(Tools::isSubmit('viewattribute_group') && Tools::getValue('id_attribute_group')) {
                $addUrl = '&viewattribute_group&id_attribute_group=' . Tools::getValue('id_attribute_group');
            }
    
            $this->redirect_after = $url . $addUrl;
        }

    Function fixes the bug too for Feature values. We need to create an override for ‘AdminFeaturesController.php’:

    <?php
    
    class AdminFeaturesController extends AdminFeaturesControllerCore
    {
    
       public function setRedirectAfter($url)
        {
            $addUrl = '';
            if(Tools::isSubmit('viewfeature') && Tools::getValue('id_feature')) {
                $addUrl = '&viewfeature&id_feature=' . Tools::getValue('id_feature');
            }
    
            $this->redirect_after = $url . $addUrl;
        }
    }
  • Prestaship 1.6 Fix for Contact form invulnerable to spam bots

    Contact form is vulnerable to spam bot. Captcha does not help in this case.
    Fix here – https://github.com/PrestaShop/PrestaShop/pull/8168/files

    Useful information on how to build an anti spam bot contact form without captcha
    http://www.nfriedly.com/techblog/2009/11/how-to-build-a-spam-free-contact-forms-without-captchas/

    Update:
    Doesn’t work well against some automated spammers. Change the friendly url of the contact-us to something else and it stopped the spamming completely.
    https://www.prestashop.com/forums/topic/442633-add-recaptcha-to-prestashop-version-16014-for-free/?page=5
    https://www.prestashop.com/forums/topic/673164-how-do-i-integrate-recaptcha-v2-into-prestashop/?tab=comments#comment-2697948

  • Prestashop: Export Pro for products, categories, combinations (paid module)

    Recommended: https://www.prestashop.com/forums/topic/429028-module-export-pro-csv-export-products-combinations-customers-categories-orders-addresses/

    Free version with less features: https://www.prestashop.com/forums/topic/37900-free-module-products-export-module-v253-updated-23032016/

  • Prestashop: Add editable product date added field in admin (prestashop 1.6)

    Source: https://www.prestashop.com/forums/topic/126518-change-date-for-products-in-bo-date-add/?p=1947106

    Add it to line 134 of: admin folder\themes\default\template\controllers\products\informations.tlp

    The if is added in case this is a new product and there is no existing date added data

    {if $product->date_add}
    <div class=”form-group”>
    <label class=”control-label col-lg-3″></td>
    <span class=”label-tooltip” data-toggle=”tooltip”
    title=”{l s=’Change date for “product new from”.’}”>
    {$bullet_common_field} {l s=’New from’}
    </span>
    </label>
    <div class=”col-lg-3″>
    <input type=”text” id=”date_add” name=”date_add” value=”{$product->date_add|escape:html:’UTF-8′}” />
    </div>
    </div>
    {/if}