Magento Themes and Magento Extensions

Understanding PHP’s OOP – basic terms explained

Share
Posted on June 28th, 2011 | Posted by admin

Hello there! I’ll explain some basic terms of PHP’s Object Orientated Programming terms that any developer needs to know. Perhaps you already use all of those, but if you don’t know which is which, you will have a problem in team communication. If so, please read on.

First of all, to understand any PHP OOP concept, you need to know the PHP basics. Then I need you to read and understand next paragraph – Procedural vs OO Programming:

Procedural programming creates a step by step program that guides the application through a sequence of instructions. Each instruction is executed in order. Procedural programming also focuses on the idea that all algorithms are executed with functions and data that the programmer has access to and is able to change. Object-Oriented programming is much more similar to the way the real world works; it is analogous to the human brain. Each program is made up of many entities called objects. Objects become the fundamental units and have behavior, or a specific purpose, associated with them. Objects cannot directly access another object’s data. Instead, a message must be sent requesting the data, just like people must ask one another for information; we cannot see inside each other’s heads.

Misuse of helper classes in Magento?

Share
Posted on June 28th, 2011 | Posted by admin

In its MVC structure, Magento allows you to throw in additional classes that might not fit in strictly under the MVC “letters”. One example of these classes are helper classes. These are usually used to isolate a certain, possibly useful, algorithm. Algorithm whose usage would be overhead to write a model as it is more static and general in nature, meaning there is no point in applying it to given instance of an object.

Calling a helper class from almost anywhere in your PHP code is extremely easy.

1
2
3
$helper = Mage::helper('catalog');
//which is same as
$helper = Mage::helper('catalog/data');

Most helpers in Magento inherit from Mage_Core_Helper_Abstract class, which by itself has several “different responsibility” methods implemented.

The principles of SOLID programming

Share
Posted on June 28th, 2011 | Posted by admin

Hello there! Today I’ll be explaining The principles of SOLID programming. When I first got serious about OOP, I jumped to design patterns, but then I realized that everyone need a good grasp of the SOLID principles before you’re ready to tackle Design Patterns – in more of an Architect role – that is. So, to conclude this short introduction, I’ll try to explain this in as low-level of knowledge as possible.

Well, yous should know that SOLID stands for:

  1. Single responsibility principle
  2. Open-closed principle
  3. Liskov substitution principle
  4. Interface segregation principle
  5. Dependency inversion principle

Why are you switching to Magento?

Share
Posted on June 28th, 2011 | Posted by admin

“Hello! I run an online store for a few years. It was developed in osCommerce originally and that’s why the sales suck. I would like you guys to move my shop to Magento. I heard a lot of good things about it and I’m sure that once we move there, our sales will skyrocket.” This is simplified version of a talk I had few days ago.

osCommerce is outdated. If this business owner wishes to continue his eCommerce business in next few years, it is true that it would be a good idea to replace osCommerce with a solution that has cleaner future. It does not have to be Magento. However, this was not the reason why he wished to move away. He believed that Magento itself will boost his sales since “everyone talks about it”.

Magento L.E.S.S.

Share
Posted on June 28th, 2011 | Posted by admin

Sometimes its all about title, right?! So, what is LESS? Well, its my fancy acronym for something utterly simply but very practical. It stands for (L)ocalhost (E)mail (S)erver (S)imulator. Basically its neither email server or simulator in the real sense of word. Its just a little trick you can apply on the “app/code/core/Mage/Core/Model/Email/Template.php” file to compensate for lack of the local email server in your development environment while developing for Magento.

Magento hadles lot of email sending, for various cases such as: Register new customer, New order created, Forgot password, etc. One of the downside of not having email server set in your local environment is that you cannot easily test all the transactional emails Magento handles. So if you are assigned task of lets say customizing email templates, possibly adding new variables to email templates, etc., then you need a good testing ground.