Archive for : November, 2010

JQuery – Ajax request with jQuery

Perform an Ajax request with jQuery:

url: 'url_of_ajax_request',
success: function(response) {
alert('Response from url is: ' + response)

Source: JQuery Ajax

Magento get front controller name

Magento get front controller name:


Magento get parameters

Get a parameter value:

$paramValue = $this->getRequest()->getParam($paramName);

Get all parameters and values:

$allParams = $this->getRequest()->getParams();

Magento get subcategories

Get subcategories of a main category:

$_cat = Mage::getModel('catalog/category')->load($cat_id);
$_subcats = $_cat->getChildrenCategories();
foreach ($_subcats as $subcat)
echo "<h1>" . $subcat->getName() . "<h1>";

Get subcategories Ids

$subcat_ids = Mage::getResourceSingleton('catalog/category_tree')->load()->getChildren($cat_id, false);

Magento Installation – 404 not found

Hack to solve the “404 Not Found error” after magento installation:

Replace in the original index.php:




Instead of ‘default’ can be used the name of default store.

Magento – TinyMCE Image Uploader / Image incorrect URL

Small hack in file: app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php
to correct image url from something like:

<img src="" />

into the correct image url.

public function getImageHtmlDeclaration($filename, $asIs = false)
$fileurl = $this->getCurrentUrl() . $filename;
$mediaPath = str_replace(Mage::getBaseUrl('media'), '', $fileurl);
$directive = sprintf('{{media url="%s"}}', $mediaPath);
$directive = $fileurl;
if ($asIs) {
$html = sprintf('', $directive);
} else {
$html = $directive;
// $directive = Mage::helper('core')->urlEncode($directive);
// $html = Mage::helper('adminhtml')->getUrl('*/cms_wysiwyg/directive', array('___directive' => $directive));
return $html;

Source: TinyMCE Image Uploader / Image inccorect URL

Magento – add contact form into a cms page

Add contact form to CMS Pages:

{{block type="core/template" name="contactForm" form_action="/contacts/index/post" template="contacts/form.phtml"}}