»
S
I
D
E
B
A
R
«
Smartpost extension installation
Feb 10th, 2010 by Sven

This page describes installation Smartpost Magento extension. As you can see, it’s quite straightforward but some tips may be helpful. You need to have a fully working Magento installed as a prerequisite. Smartpost extension requires at least Magento version 1.3.

We call your website your.magento-site.com. Replace it with fully qualified name of your website.

  1. Extract the Magento_Smartpost.zip archive to a temporary folder. This is your $source folder. Your Magento installation folder is your $destination folder.
  2. Copy files and folders from $source/app folder to $destination/app folder. It is important to copy all included subfolders and their structure!
    Example in Linux: go to source folder, for example cd vhosts/your.magento-site.com/tmp. This is where you unpacked the files. app folder is vhosts/your.magento-site.com/tmp/app. So you’re in tmp folder and your Magento installation is in vhosts/your.magento-site.com/htdocs
    Then copy the app folder like this: cp -R app ../htdocs/app
  3. Now remove your Magento cache from $destination/var/cache (delete that folder). Also remove $destination/app/etc/use_cache.ser if it exists.
  4. Open your Magento admin and go to System->Configuration->Shipping Methods. You should see Smartpost there.
  5. Configure your Smartpost. Most fields should be self-explanatory.

List of Smartpost destinations.

Release notes of Magento Banklink 1.3.6
Sep 28th, 2009 by Sven

Version 1.3.6 (built 2009-09-28)
- Fixed payment status, correct bank names are displayed
- and new user registration
- Changed new order status to “pending”

Please see information about new order status

v3nr6ka59g
Sep 23rd, 2009 by Sven

v3nr6ka59g

Fast and good-looking templates in PHP
Aug 14th, 2009 by Sven

This is the second article in serie of articles about using PHP in a better way than an average script-kiddie. You want to be better than an average, right?;) Then read on…

In my house no one likes spaghetti when it’s in code. That’s why we at Wasabi developed a way to separate presentation from content and code already hmm… how many years ago. I don’t know. I know that buzzword of MVC was not around yet… :) However – since we don’t need yet another mambo-jambo-fancy templating language then we need to use minimum set of code in templates also. So, let’s start.

It uses best parts of PHP like dynamic including and output buffering.

First Model-View-Controller a.k.a. MVC. It’s good, it’s easy but don’t take it like it would be the “final solution” or like it would solve all your problems. It won’t.

First let’s create a simple controller:

<?php
/**
 * Controller is invoked when web server gets a request.
 * For simplicity's sake we don't implement
 * fancy URL-to-controller-and-action mapping logic
 * This is usually done by our framework PHP-X.
 *
 * @author Sven Varkel
 */
class Controller
{
    /**
     * This is the initial action
     * that will be called by default
     *
     * @return string
     */
    public function defaultAction()
    {
        /*
         * Let's create model. This holds
         * our data. Model can be used to load data
         * from database or anywhere else.
         */
        $model = new Model();
        $model->setTitle('Mr');
        $model->setAge(33);
        $model->setFirstName('Sven');
        $model->setLastName('Varkel');
        $model->addHobby('Music');
        $model->addHobby('Fishing');
        $model->addHobby('Cooking');

        /*
         * Here we instantiate View
         * that loads a view
         * and then fills the template with data
         * that comes from the prepared
         * model. After that we render
         * the view to a wanted format.
         * In our case the format is HTML
         * but it can be PDF, XML, WML ...
         */
        $view = new View('person');
        $view->setModel($model);
        $renderedView = $view->render();

        /*
         * Finally we return rendered view
         * for output
         */
        return $renderedView;
    }
}
//EOF Controller.php

Then we create a Model …

<?php
/**
 * Model is a structure that
 * holds our data. Model or model helper
 * can be used to pull and push data from/to a data source
 * (e.g database)
 * It can also include operations for data manipulation.
 * Just to keep things clear and easy-to-understand I recommend
 * to NOT put too much logic inside a model. Use helpers for that.
 *
 * @author Sven Varkel
 */
class Model
{
    private $title = null;
    private $age = 0;
    private $firstName = null;
    private $lastName = null;
    private $hobbyList = array();

    /**
     * Gets Title
     *
     * @return Title
     */
    public function getTitle(){
        return $this->title;
    }
    /**
     * Sets Title
     *
     * @param Title
     */
    public function setTitle($value){
        $this->title = $value;
    }
    /**
     * Gets Age
     *
     * @return Age
     */
    public function getAge(){
        return $this->age;
    }
    /**
     * Sets Age
     *
     * @param Age
     */
    public function setAge($value){
        $this->age = $value;
    }
    /**
     * Gets FirstName
     *
     * @return FirstName
     */
    public function getFirstName(){
        return $this->firstName;
    }
    /**
     * Sets FirstName
     *
     * @param FirstName
     */
    public function setFirstName($value){
        $this->firstName = $value;
    }
    /**
     * Gets LastName
     *
     * @return LastName
     */
    public function getLastName(){
        return $this->lastName;
    }
    /**
     * Sets LastName
     *
     * @param LastName
     */
    public function setLastName($value){
        $this->lastName = $value;
    }
    /**
     * Gets HobbyList
     *
     * @return HobbyList
     */
    public function getHobbyList(){
        return $this->hobbyList;
    }
    /**
     * Sets HobbyList
     *
     * @param HobbyList
     */
    public function setHobbyList($value){
        $this->hobbyList = $value;
    }
    /**
     * Adds hobby with name $aHobby
     * to the list of hobbies
     *
     * @param $aHobby
     * @return
     */
    public function addHobby($aHobby){
        $this->hobbyList[] = $aHobby;
    }
    /**
     * In this override helper we
     * create getter names
     *
     * @param $theName
     * @return mixed
     */
    public function __get($theName){
        $getterName = sprintf('get%s', $theName);
        return $this->$getterName();
    }
}
//EOF Model.php

Then we create a View…

<?php
/**
 * This is the view that will
 * be rendered using a template
 *
 * @author Sven Varkel
 */
class View
{
    private $name = null;
    private $path = null;
    private $model = null;
    /**
     *
     * @param $theName
     * @return
     */
    public function __construct($theName){
        $this->setName($theName);
    }
    /**
     * Gets Name
     *
     * @return Name
     */
    public function getName(){
        return $this->name;
    }
    /**
     * Sets Name
     *
     * @param Name
     */
    public function setName($value){
        $this->name = $value;
    }
    /**
     * Gets Model
     *
     * @return Model
     */
    public function getModel(){
        return $this->model;
    }
    /**
     * Sets Model
     *
     * @param Model
     */
    public function setModel($value){
        $this->model = $value;
    }
    /**
     * Gets Path
     *
     * @return Path
     */
    public function getPath(){
        return $this->path;
    }
    /**
     * Sets Path
     *
     * @param Path
     */
    public function setPath($value){
        $this->path = $value;
    }
    /**
     * This method renders the view.
     * It loads template with slots
     * and it loads data from the model into
     * template slots.
     *
     * @return string
     */
    public function render(){
        /*
         * First we start output buffering.
         * This is critical!
         */
        ob_start();
        /*
         * Then we include the template.
         * Look at the fields inside the template!
         * Also look at how we create path of
         * the template.
         */
        $templatePath = sprintf('view/%s.tpl.php', $this->getName());
        /*
         * This is the funny trick to include template here.
         * Template becomes PART OF this class!
         * So we can use all methods from this class
         * inside our template
         */
        include $templatePath;

        /*
         * Here we collect the contents from
         * the buffer to variable $outstr
         */
        $outstr = ob_get_contents();

        /*
         * Here we end output buffering for this level
         */
        ob_end_clean();
        /*
         * Return rendered view
         */
        return $outstr;
    }
    /**
     * Returns slot value.
     * It loads value with given name from
     * the model
     *
     * @param $theName
     * @return mixed
     */
    public function getSlot($theName){
        return $this->getModel()->__get($theName);
    }
}

... and here is the template

<div>
 <h3>Personal information</h3>
 <div>
 Name and title: <?=$this->getSlot('Title')?> <?=$this->getSlot('FirstName')?> <?=$this->getSlot('LastName')?>
 </div>
 <div>
 Age: <?=$this->getSlot('Age')?>
 </div>
 <div>
 <h3>Hobbies</h3>
 <?php
 /**
 * Pay attention to this foreach. This is the elegant way
 * to use php code inside a template.
 * Code is nice and clean, easy to read.
 *
 * Use of PHP short tags is recommended, it makes code much nicer.
 * However - you can use long opening tag as well but then
 * you have to use echo instead of =
 */
 ?>

 <?foreach( $this->getModel()->getHobbyList() as $hobby ):?>

 <div><?=$hobby?></div>

 <?endforeach?>

 </div>
</div>

… and then we clue all pieces together

<?php
/**
 * This script may be called as Front Controller.
 *
 * This one takes the hits. It can ve called directly
 * but it's also very common to use rewrite that makes the URL-s
 * nicer and sends all requests to this script regardless of their
 * visible URL.
 */

/*
 * First include our required classes
 */
require_once '../lib/Model.php';
require_once '../lib/View.php';
require_once '../lib/Controller.php';

/*
 * Instantiate our default controller
 */
$controller = new Controller();

/*
 * Call default action in our controller
 */
echo $controller->defaultAction();

//EOF index.php

OK, that’s it!

This is a simple way to make MVC work for you. The trick of template is that we include it inside a class. The template which is actually made of fragments of PHP code becomes part of the class. Template can use methods of class. It can load data into itself in a clever, fast and elegant way.

All comments to this technique are welcome!

Magento Banklink module version 1.2.3 released
Jul 26th, 2009 by Sven

Today we released Magento Banklink module version 1.2.3. Please consider upgrading to the latest version.

Existing customers – please don’t hesitate to contact Wasabi to ask for the upgrade. This is for free for you!

Changelog follows:

Version 1.2.3
- Fixed bug no #11. Order status was updated twice after click “Back to merchant” in a bank

Version 1.2.2

Version 1.2.1 (built 2009-07-09)
- Fixed _getSession() in ReturnController

Version 1.2.0 (built 2009-07-08)
- Added new function “auto send invoice”. Generates and sends invoice automatically after banklink payment. Configurable in admin.

Version 1.1.3 (built 2009-06-25)
- Fixed creation of invoice in admin. After banklink payment a faulty invoice is not created anymore. Invoice can be e-mailed now manually.
- Fixed banklink i18n in info block
- Added short install guide in Estonian

Version 1.1.2 (built 2009-06-16)
- Fixed missing info.phtml in admin

Version 1.1.1 (built 2009-06-14)
- Fixed some more localizations
- Fixed success page of payment

Version 1.1.0 (built 2009-06-14)
- Added uninstall script
- Added correct license info to template and layout files
- Fixed missing translations

Version 1.0.1 (built 2009-06-14)
- Fixed bugs regarding rewrite and that all payments ended up banklink success page

Version 1.0.0
Initial release. Banklink supports Swedbank, Sampopank and SEB.

Avasime Wasabi uue veebisaidi
May 16th, 2009 by Sven

Täna, 16. mail 2009 avasime siin  Wasabi OÜ uue veebisaidi. Veebisait kasutab Wordpressi sisuhaldusmootorit. Palun jäta meile siia kommentaar, et saaksime seda veebilehte ning Wasabit veelgi paremaks muuta.

Today, on May 16th, 2009 we opened brand new website of Wasabi Ltd. Please feel free to leave a comment here to help us to improve this website and Wasabi.

Hello world!
Mar 5th, 2009 by Sven

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!

»  Substance: WordPress   »  Style: Ahren Ahimsa
© Copyright Wasabi Ltd 2009