Prestashop Sort Attributes the Easy Way

Prestashop is a great piece of e-commerce, but one thing I with they would add is the ability to sort attributes in the backend for display on the front end of the web site. As we know, alphabetical order is not always the way you might want to display a list of product attributes on a product detail page. For example, a list of sizes like (s,m,l,xl) is best displayed in smaller to larger order, not alphabetical. There are several posts that require editing some of the core classes of Prestashop to sort the attributes by id, basically ordering them in the order they were put in the system.

The method I came up with was to add a function to smarty, the template processor and then sort the array in the product.tpl file. This article is what got me started:

http://www.smarty.net/forums/viewtopic.php?t=1079&postdays=0&postorder=asc&start=0

Here’s what I did:

  1. Created a file called modifier.sortby.php in tools/smarty/plugins/
  2. Place this code in the file
    <?php
    #
    # Modifier: sortby – allows arrays of named arrays to be sorted by a given field
    #
    function smarty_modifier_sortby($arrData,$sortfields) {
    ksort($arrData);
    return $arrData;
    }
    // You might need this for smarty to load the function, probably not
    //$smarty->register_modifier( “sortby”, “smarty_modifier_sortby” );
    ?>
  3. Use this foreach loop in your .tpl file – @sortby:”key you are sorting by here”
    {foreach from=$group.attributes|@sortby:”#id_attribute” key=id_attribute item=group_attribute}

Hope this helps someone!


Drupal Ubercart White Screen of Death Problem

I nearly went insane trying to solve a problem where adding to cart or doing anything in the cart caused the dreaded White Screen of Death or WSOD. I tried increasing memory limit, checking error logs, to no avail. I narrowed the problem down to the theme I had developed, as Garland didn’t cause the


Magento URL Mistake No Access to Backend Admin Area

The urls set in the Magento Admin -> Configuration  -> Web are used to build all the urls to the css and js files, if you make a mistake saving them and they don’t resolve properly, that means all the references are off and breaks the site. This means your site won’t appear or function properly


Changing Magento Validation

To change magento checkout validation, you can change the class of the form field to use one of the other validation methods present in js/prototype/validation.js. Just open that file and scroll down to see the methods available. Search fo r this Validation.addAllThese and you’ll see the methods below. Then open up /app/design/frontend/default/YOUR THEME/template/checkout/onepage/billing.html then change


Mystery Space Caused by the Byte Order Mark (BOM)

This took way too long to figure out, hopefully this will help someone else. If you have a mystery space occurring somewhere in your web site and it is not one of the many CSS bugs out there then the byte order mark might be the culprit. Here’s a quote taken from the Joomla forums:


Hi Class

TESTING


Customizing Joomla 1.5 and VirtueMart

I’m thinking it might be a good idea to record the changes I’m making to Joomla 1.5 for posterity. Hopefully I can consult this post when setting up a similar site in Joomla in the future and others can as well. So here goes. 1. First thing — installed Joomla, then installed the VirtueMart package.


Web Site Maintenance Overview

Web site maintenance is the ongoing process of updating content, design and functionality of a web site.


Planning a Web Site Project

This phase occurs before hiring a designer/developer/company. Before requesting a proposal from a potential designer/developer/company you will need to collect and summarize your ideas about your project.


Web Site Promotion Overview

Web site promotion is the continuing process to promote a web site to attract more visitors to the web site.