Tag Archives: Languages

Magento Architecture – Blocks, Models, Helpers

Magento is structured from many small modules working and existing as atomicly as possible. The typical Magento architecture for each module is divided on Blocks, Models, Helpers.

Tips: If you want to see more about most Magento interesting configuration one good class for that is core/code/Mage/Core/Model/Config.php

Now the interesting part have you thought why there are Mage::getModel(”) and Mage::getResourceModel(”) but Mage::helper?

Well, I still have not answer to that question. XD

But I have thought a lot of why you are able to get Mage::helper(‘unique_name’) but you able only to that -> Mage::getModel(‘unique_name/filename’) for the models.

Well, the answer is easy and it is in core/code/Mage/Core/Model/Config.php


public function getModelClassName($modelClass) {
    $modelClass = trim($modelClass);
    if (strpos($modelClass, '/') === false) {
        return $modelClass;
    }
    return $this->getGroupedClassName('model', $modelClass);
}

public function getHelperClassName($helperName) {
    if (strpos($helperName, '/') === false) {
        $helperName .= '/data';
    }
    return $this->getGroupedClassName('helper', $helperName);
}

In the helper one Magento configuration adds automatically /data if there is no slash in the $helperName so if you write something from this kind Mage::helper(‘unique_name’) it is presenting Data.php file in your Helper folder that this unique_name is defining it will be loaded automatically.

Magento Admin Redirect

How can you redirect the user request from your custom module to Magento Admin Core module?

If my module is in the local or the community pool and we want to redirect an action from the controller in our module to a controller in the core module the easiest way to make that Magento Admin redirect is:


public function someAction() {
    //general syntax $this->_redirect("adminhtml/module/action", params)
    $this->_redirect("adminhtml/sales_order/view", array('order_id', '11'));
}

JQuery Multiselect – Abbreviation List

Recently I had a struggle with jQuery Multiselect Widget.

As general it is really flexible and easy to use, but I was willing to have a list with abbreviation of all selected values (separate with commas)

More or less it should look like that at the end:

Continue reading JQuery Multiselect – Abbreviation List