Author: admin

  • Prestashop: Add tags to the product list

    Source: http://nemops.com/prestashop-product-list-tags/#.XPt5M7hS-Ul

    1) Product.php class (use override)

    Insert code at the last part of public static function getProductProperties($id_lang, $row, Context $context = null)
    /* add product tags to product list */
    $row['tags'] = array();
    $tags = Tag::getProductTags($row['id_product']); //show product tags in listing
    if($tags && isset($tags[$context->language->id])) //show product tags in listing
    $row['tags'] = $tags[$context->language->id]; //show product tags in listing

    2) product-list.tpl (in theme folder)
    <div class="product-tags">{if $product.tags}{foreach from=$product.tags item=tag}<a class="btn bth-default" href="{$product.link|escape:'html':'UTF-8'}" title="{$tag|escape:'html':'UTF-8'}" >{$tag}</a>{/foreach}{/if}</div>

    3) global.js (in theme folder) add this above the product-reference html in 3 views (grid, table, list) it looks for product-tags name in div so make sure that matches in product-list.tpl
    html += '<div class="product-tags">'+$(element).find('.product-tags').html()+'</div>';

    Note: no all products have tags, so may mess up the listing layout. Add a min-height to the product-container to e.g. 500px

  • Prestashop: Remove View Grid/List buttons from Product Listing

    Source: https://www.prestashop.com/forums/topic/337353-remove-view-gridlist-bottons/

    Open themes/yourtheme/product-sort.tpl and find this code:

    <ul class="display hidden-xs">
        <li class="display-title">{l s='View:'}</li>
        <li id="grid"><a rel="nofollow" href="#" title="{l s='Grid'}"><i class="icon-th-large"></i>{l s='Grid'}</a></li>
        <li id="list"><a rel="nofollow" href="#" title="{l s='List'}"><i class="icon-th-list"></i>{l s='List'}</a></li>
    </ul>

    Delete it and buttons will gone.

  • 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: Searching orders by the products they contain via mysql

    Source: https://www.prestashop.com/forums/topic/437518-searching-orders-by-the-products-they-contain/?tab=comments#comment-2033625

    SELECT product_id, product_attribute_id, product_name, GROUP_CONCAT(id_order SEPARATOR ‘, ‘) AS orders FROM ps_order_detail group by product_name order by product_id, product_attribute_id

    Can add where product_id = to the number you want to narrow down the specific product

    SELECT product_id, product_attribute_id, product_name, GROUP_CONCAT(id_order SEPARATOR ‘, ‘) AS orders FROM ps_order_detail where product_id = XYZ group by product_name order by product_id, product_attribute_id

  • 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