home | contact us
» Posts tagged "developer"

Items Tagged: developer


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.

Modules

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.

Themes

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:


my_module
My Module
1
A test module, it does nothing
My self
front_office_features
0
1

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.


 

Responsive web design is an excellent way to make a site work really well for a variety of different screen sizes without having to serve more than one design to users. Responsive web design does pose additional challenges however.

Some of the challenges for you, as the developer, are being able to implement, test and debug the design implementation. Fortunately built in to Firefox’s arsenal of developer tools is an interface for exactly that!

Lets take a website that uses a responsive design:

Here is the ‘mobile’ view:

So every thing is normal you can use the developer tools and Firebug or whatever. If you then need to make changes to the smaller version and use Firebug you would have to pop out Firebug (which may or may not be to your preference) then resize the main window. This works ok but Firebug currently isn’t great for working with responsive designs as it doesn’t show you all the rules that might apply based on the screen size and other conditions. This is one area that the Firefox built in tools beat Firebug. The styles editor shows you all rules that could apply and their conditions.

To activate Firefox’s responsive design view press Ctrl + Shift + M. You can open the inspector and stlyes by pressing Ctrl + Shift + I. You can also access the responsive design view by going to Tools Web Developer. With responsive design view enabled you can still use Firebug without a problem, unless you enable the built in element inspector then you kind of lose loads of screen space.


 

When you’re uploading multiple files (HTML5 feature – remember IE as yet STILL does not support this), it may not be the fact you’re uploading multiple files that’s actually causing the problem.

The problem often is actually caused by the various php memory limits in play, one way to avoid getting caught by this is using the following snippet in the form’s php to remind you which restrictions are in play (note the min_by_key() function is from the php.net comments) :-

<?php
function min_by_key($arr, $key){
    $min = array();
    foreach ($arr as $val) {
        if (!isset($val[$key]) and is_array($val)) {
            $min2 = min_by_key($val, $key);
            $min[$min2] = 1;
        } elseif (!isset($val[$key]) and !is_array($val)) {
            return false;
        } elseif (isset($val[$key])) {
            $min[$val[$key]] = 1;
        }
    }
    return min( array_keys($min) );
}

$arrayMaxes = array(
    'upload_max_filesize'=>intval(ini_get('upload_max_filesize')),
    'post_max_size'=>intval(ini_get('post_max_size')),
    'memory_limit'=>intval(ini_get('memory_limit'))
);
$maxUploadSize = min($arrayMaxes);
foreach ($arrayMaxes as $key=>$value) {
    if ($value == min($arrayMaxes)) {
        $minimumOfThree = $key;
    }
}?>
<p>Max filesize <?php echo $maxUploadSize; ?>M Maximum filesize due to server setting <?php echo $minimumOfThree; ?> in php.ini</p>

 

All developers love code completion, but sometimes the minimalist info that can come up in PHPStorm can be not quite enough.

Netbeans gave an excerpt that gave plenty of information from the docblock, and PHPStorm can do too, it just defaults to off.

The setting is under Editor-Code Completion and is “Show full signatures”. The good news is it is an “IDE Setting” so it persists for all projects, the bad news is that that means the setting will be forgotten about before you next reinstall and want it again.


 

Magento Certified Developer Logo I’m really happy to announce that two of our team have now taken and passed the Magento Certified Developer exam. This means that they are now officially “Magento Certified Developers”.

What that means for you is that you can be assured that we have the in house skills and experience to work the right way with Magento and really help you get the most out of the platform.

The reason we finally put them forward for the exam is that, after working with the platform for a few years now, we have decided to go down the official Magento partner route and get all the qualification and assurance that you could ask for by becoming an Silver Magento Partner and employing developers who are not only Zend Certified Engineers – a PHP qualification – but also Magento Certified Developers.

The exam asks questions on a wide range of Magento topics ranging from the basics through to layout, rendering and then more complex subjects such as the checkout, sales, API and more. You can download the official Magento Certified Developer study guide to see the full details of the areas that are discussed though suffice to say it is really quite in depth and broad. You definitely need to know Magento well to pass the exam.

For those that care the passing mark for the exam is 37 out of 70 questions. Our devs passed with 54/70 and 52/70 so really nailed it!


 

If you pull down a Magento site to a local machine, and change the database core_config table to point to the local machine, and it appears to work fine until you try to login to the site admin, there can be many issues.

One of the most common ones though is not having a period (dot) in the host name – e.g. localhost/admin or martyn-desktop/admin – if you don’t have the period, the cookies don’t work properly and you end up in a login loop.

To fix it, make sure your machine is accessible via a domain with a period – e.g. martyn-desktop.local – by either editing your hosts file (/etc/hosts) or check your router – it possibly already adds a domain name like .config and set your path in core_config to the same.


 

Recently the good folks at chrome have added a feature where you can reload without the cache, which is in a right-click on the reload button, but I was really confused as some machines seem to have it and others don’t.

The key is whether developer tools is open or not! If you’re using a recent version of chrome, press F12 to open the developer tools and then you can right-click the reload button, and you get three options – Reload, Hard Reload (redownloads images) and Empty Cache and Hard Reload.


 

Followers of this blog will remember the Replicate Netbeans “Select in project” in phpstorm post which gave a handy key combo to select the current file in the project window.

It has been brought to our attention that there’s also a button to do this with the mouse in one click!  At the top of the Project window, there’s a cross-hair/target icon labelled a rather cryptic “Scroll from Source”.  Click that and it does what netbeans users will be looking for as “Select in Projects”

So there you have it, “Scroll from Source”, is the magic words that you want.


 

This is a very small tip, but one that can really save accidents in the long term.

To display the current branch in git simply add the following to your .bashrc in your home directory :

__git_ps1 () 
{ 
    local b="$(git symbolic-ref HEAD 2>/dev/null)";
    if [ -n "$b" ]; then
        printf " (%s)" "${b##refs/heads/}";
    fi
}

PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\$( __git_ps1 ) \$\[\033[00m\] "

This is based on the Linux Mint prompt so is nicely coloured as well.


 

According to pretty much every source there’s only one sensible way to migrate from 5.0, 5.1 or 5.2 to 5.5 of mysql (or mariadb/percona for that matter), and it’s not pretty (for a server with only two active magento installations for instance, this will take about 3 hours).

The answer is that you have to do an sql dump and restore. This does take an age but does at least provide the reassurance that you are going to have nice clean databases after the upgrade.

So the commands are :-

mysqldump --all-databases --routines --events > fulldump.sql
mysqldump mysql --tables user > users.sql

Then upgrade mysql binaries to 5.5 and empty the database directory – such as /var/lib/mysql and start mysql with it’s script (e.g. /etc/init.d/mysql start). Note, if you’re using a distribution that doesn’t come with start scripts, you may want to run mysql_install as root before starting mysql however you start it.

Then the following will restore the databases and users :

mysql -u root # add -p if you set up a default password when upgrading/installing 5.5
\r mysql
source users.sql
source fulldump.sql
FLUSH PRIVILEGES;
\q

 
rss icon