Like most frameworks and software packages PrestaShop has it’s own way of handling session variables.
PrestaShop uses the Cookie class to manage session variables. While this isn’t strictly a singleton you can get a pre initialised instance using Context::getContected-cookie if the FrontController-init() method has been called already.
The Cookie class uses the magic __get __isset __set __unset magic methods to handle parameters. Parameters set in the cookie are actually given to the client in an encrypted blob. This is good because it means sessions are not really stored on the server. This does mean, however, that only scalar values can be stored in the session. To store non-scalar values you can usually get away with serialising them but there are some restrictions even then. If you do struggle to store serialised values you can base64 encode them to fix any remaining issues.
Once you have set your variables you need to call the write method to save your variables to the cookie.
PrestaShop is a fully featured shopping platform and offers much of the functionality that other eCommerce shopping platforms do. Compared to, for example, Magento PrestaShop is significantly simpler to develop for.
Here is the run down of the key aspects that any one building a web site on PrestaShop should be aware of.
PrestaShop is based around a modular design which is quite similar to Joomlas module system.
A modules presence and position on the front end is defined by hooking the module into a particular section on the frontend. There are loads of hooks that can be used. Most modules will add them selves to the hook they think is most appropriate on install. The ordering of modules also defines the order they appear in a given hook.
A key point of managing modules that can easily be over looked is that you can grab and drag modules in a given hook by clicking and holding the position change buttons.
Off the shelf themes are usually not simply a new set of templates and CSS but also modules as well. Quite allot of themes are built around specific modules being in specific hooks some times in a specific order.
Creating your own module
Defining your own module is really straight forward:
Create a folder in modules called my_module.
Create a file called my_module.php, in this file create a class called My_module which extends Module.
Create a config.xml with the following template:
A test module, it does nothing
Done, the module will appear in the module list but do nothing. You can look at the base module class to see all the function available that get called by PrestaShop are different times to do what you need to do.
PrestaShop has a really nice structure for handling all the CSS that will appear in a site. It starts by splitting the CSS so that the CSS is split up per modules. There is a global CSS sheet but this should only be used for things that genuinely appear on all pages.
Extending the CSS of a module in PrestaShop is easy. All you need to do is create a CSS file that matches the naming convention of the module you are looking to extend.
For example if you wanted to change the CSS of the “Wishlist block” module (a.k.a. blockwishlist) in your theme, you would create the file themes/mytheme/css/modules/blockwishlist/blockwishlist.css. This file will then be included on every page that the CSS from the blockwishlist module appears on.
This system is good because it minimises the amount of CSS the browser has to load and also splits the concern of CSS into separate files making it much easier to manage. It also makes adding to a modules CSS with in a theme much easier.
One problem with this method of handling CSS is that by default a PrestaShop site may want the browser to download ten or more individual CSS files which is quite a overhead. Fortunately since PrestaShop 1.4 it has supported CCS merging (referred to as CCC in the admin) which causes the CSS for a page to be merged into a single file on the server to prevent the client having to download tens of CSS files.
Edmonds Commerce are a UK based e-commerce development specialist and along with osCommerce and Magento development, we also do work on Prestashop.
Prestashop is a nice modern open source ecommerce platform that uses a lot of jQuery to get some nice user interface effects.
If you are looking for a company that can help you customise your Prestashop based store, fix bugs or generally do PHP development work then get in touch today.