Prestashop disable smarty cache

Smarty cache is great for server performance on production but is annoying on developpement.
Hopefully, you can enable or disable it.

On prestashop 1.3.x or less, you have to edit the root/config/smarty.config.php and edit these 2 lines

$smarty->caching        = false;   // to pass "true" when put into production
$smarty->force_compile  = true;    // to pass "false" when put into production

On prestashop 1.4.x or more, you can do it directly on the backoffice, preference tab, performences subtab

Magento : list all values of an attribute

You want to see all values of an attribute, for debug purpose or something else ?

$attr_model = Mage::getModel('catalog/resource_eav_attribute');
$attr_model->load(959); // you can find the attribute_id on the eav_attribute table
$options = $attr_model->getSource()->getAllOptions(false);
foreach($options as $value)
{
     print_r($value);
     echo "<br />";
}

You will get something like that :

Array
(
    [value] => 154
    [label] => 2008
)
Array
(
    [value] => 155
    [label] => 2009
)
Array
(
    [value] => 156
    [label] => 2010
)

Mysql INSERT … ON DUPLICATE KEY UPDATE

If you want to do some data loads in a Mysql DB regardless of insert or update statement you can use the INSERT … ON DUPLICATE KEY UPDATE request.

INSERT INTO test (firstname, lastname, skill)
      VALUES
      ('Alan', 'Cox', 98),
      ('Robert', 'Love', 85),
      ('Linus', 'Torvalds', 24),
      ('Rusty', 'Russell', 79)
ON DUPLICATE KEY UPDATE
     skill = VALUES(skill);

In this example, if the key is composed by firstname and lastname, when a duplicate key is detected, only the skill will be updated

You could find more informations on this statement here

PHP Fatal error: Method Gregwar\\ImageBundle\\ImageHandler::__toString() must not throw an exception in /home/www/recette/app/cache/dev/classes.php on line 7426

You are using the fanstactic Gregwar/ImageBundle code to manipulate your images on Symfony2 and twig.
But instead of rendering your website, you get this error on your apache error log file

PHP Fatal error:  Method Gregwar\\ImageBundle\\ImageHandler::__toString() must not throw an exception in /home/www/recette/app/cache/dev/classes.php on line 7426

or directly on your html genered code

<img src="
Fatal error: Method Gregwar\ImageBundle\ImageHandler::__toString() must not throw an exception in /home/www/recette/app/cache/dev/classes.php on line 7426

this issue may be a rights problem on your cache drectory. By default, gregwar cache directory is on your web so, launch this command

chmod 777 web/cache

This error may also occur if the file doesn’t exist, for a clean code, add

{% if file_exists('uploads/' ~ site.id ~ '.jpg') %}
    {{ image(site.picture).resize(250, 50) }}
{% endif %}

or on twig code

{% if site.has_picture %}
    {{ image(site.picture).resize(250 ,50) }}
{% endif %}

For more informations about file_exists, see here Symfony2 twig add new function file_exists

You need to enable either the SQLite3 or PDO_SQLite extension for the profiler to run properly.

After installing Symfony 2 instead of viewing your website, you see this error message :

You need to enable either the SQLite3 or PDO_SQLite extension for the profiler to run properly.

It probably means you need to install the sqlite extension for php

apt-get install php5-sqlite

restart apache and that should to the tricks.

Gestion des droits d’accès dans le backend de Magento

Imaginons qu’on ait une entrée de menu qui ressemble à ceci :

...
        <menu>
            <mon_module translate="title" module="adminhtml">
                <children>
                    <mon_entree>
                        <title>Le titre de mon menu</title>
                        <action>maroute/adminhtml_index</action>
                    </mon_entree>
                </children>
            </mon_module>
        </menu>
...

alors si on veut pouvoir gérer les droits d’accès via le menu permission alors il suffit d’ajouter

...
        <menu>
            <mon_menu translate="title" module="adminhtml">
                <children>
                    <mon_entree>
                        <title>Le titre de mon entrée dans le menu mon_menu</title>
                        <action>maroute/adminhtml_index</action>
                    </mon_entree>
                </children>
            </mon_menu>
        </menu>
        <acl>
            <resources>
                <admin>
                    <children>
                        <mon_menu translate="title" module="mon_module">
                            <title>Le titre du menu qui va apparaître dans les permissions</title>
                            <sort_order>100</sort_order>
                            <children>
                                <mon_entree translate="title" module="mon_module">
                                    <title>Le titre de mon entrée de menu qui va apparaître dans les permissions</title>
                                    <sort_order>10</sort_order>
                                </mon_entree>
                            </children>
                        </mon_menu>
                    </children>
                </admin>
            </resources>
        </acl>...

voilà c tout…