Features Visibility in Prestashop

July 10, 2014 Alex Simonchik Prestashop
Features Visibility in Prestashop

Quite often store owners or developers need to create new features which they do not want to be visible on the product page.  To solve this problem I have created a new Visibility module which makes it possible to enable or disable visibility for each feature.

The module itself:

1Features Visibility in Prestashop

The new visibility field:

2Features Visibility in Prestashop

The module installs a new Visibility column which also indicates whether the visibility is on/off for a specific feature.

3Features Visibility in Prestashop

I used the following products for testing:

http://presta.digital.salling.dk/vin-og-gourmet/spiritus/grappa/castello-banfi-acquavite-di-moscato-italien_5127.html

Without the module

4Features Visibility in Prestashop

With the module

5Features Visibility in Prestashop

http://presta.digital.salling.dk/vin-og-gourmet/vin/rodvin/les-songes-de-magdelaine-grand-cru-saint-emilion-frankrig-2006_5131.html

Without the module

6Features Visibility in Prestashop

With the module

7Features Visibility in Prestashop

To add font verification we need to edit product.tpl.

To add to product.tpl, before “{foreach from=$features item=feature}” :

To apply this module to the populal module PM_MultipleFeatures you need to modify the method pm_multiplefeatures as follows:

 



4 comments

  1. Hi

    thanks for the the module it’s working great. I was wondering if there was a way to use it in the product list as well as the product page.
    I’ve tried the same code as for the product but it doesn’t work for me :

    {* Check features visibility *}
    {assign var=”features” value=Module::getInstanceByName(‘belvg_featurevisibility’)->getFrontFeatures($product->id, ‘, ‘)}
    {* /Check features visibility *}
    {foreach from=$product.features item=feature}

    {$feature.name}: {$feature.value}

    {/foreach}

    Thanks

    Laurence

  2. Laurence,

    Thanks for your feedback :) Most probably the problem is that in the code which you provided use the object $product, from which you get ID, but on the catalog page this is not an object but an array, so the proper way would be to refer to {$product.id} but not to {$product->id}

  3. Great module!

    Just a little improvement…

    The features do not show in the product page taking in account the “position” parameter you set up in the Product Features admin area.

    So, all it is needed to fix this issue is adding a simple line of code to your “belvg_featurevisibility.php” file.

    The SQL query located in the “getFrontFeatures” public function needs this ORDER clause:

    ORDER BY f.position ASC’

    So, the new query must look like this:

    $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(‘
    SELECT fp.id_feature, vl.value, fl.name
    FROM '._DB_PREFIX_.'feature_product fp
    LEFT JOIN '._DB_PREFIX_.'feature_value v ON (fp.id_feature_value = v.id_feature_value)
    LEFT JOIN '._DB_PREFIX_.'feature_value_lang vl ON (v.id_feature_value = vl.id_feature_value AND vl.id_lang = ‘.(int)$id_lang.’)
    LEFT JOIN '._DB_PREFIX_.'feature f ON (f.id_feature = v.id_feature)
    LEFT JOIN '._DB_PREFIX_.'belvg_featurevisibility bfv ON (f.id_feature = bfv.id_feature)
    ‘.(version_compare(_PS_VERSION_, ‘1.5.0.0’, ‘>=’) && Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP ? Shop::addSqlAssociation(‘feature’, ‘f’) : ”).’
    LEFT JOIN '._DB_PREFIX_.'feature_lang fl ON (fl.id_feature = f.id_feature AND fl.id_lang = ‘.(int)$id_lang.’)
    WHERE fp.id_product = ‘.(int)$id_product.’ AND bfv.visibility = 1
    ORDER BY f.position ASC’
    );

    Thanks for your great contribution!

Post a new comment

top
BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *