Magento – Display Categories (with category images) in the homepage

Share
Posted on September 9th, 2011 | Posted by admin

<div>
<?php
/*
$_helper    = $this->helper(‘catalog/output’);
$_category  = $this->getCurrentCategory();
$_imgHtml   = ”;

if ($_imgUrl = $_category->getImageUrl()) {
$_imgHtml = ‘<p><img src=”‘.$_imgUrl.’” /></p>’;
$_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, ‘image’);
}*/
?>

<?php // Iterate all categories in store
$limit = 0;
$_helper    = $this->helper(‘catalog/output’);
foreach ($this->getStoreCategories() as $_category):

// If category is Active
if($_category->getIsActive()):

// Load the actual category object for this category
$cur_category = Mage::getModel(‘catalog/category’)->load($_category->getId());

if ($_imgUrl = $cur_category->getImageUrl()){

$_imgHtml = ‘<img src=”‘.$_imgUrl.’”  width=”105px” />’;
$_imgHtml = $_helper->categoryAttribute($cur_category, $_imgHtml, ‘image’);
} ?>
<div>
<div>
<a href=”<?php echo $this->getCategoryUrl($cur_category) ?>” style=”border:none”>
<?php echo $_imgHtml; ?>
</a>
</div>
<div>
<a href=”<?php echo $this->getCategoryUrl($cur_category) ?>”>
<?php echo $_helper->categoryAttribute($cur_category, $cur_category->getName(), ‘name’) ?>
</a>
</div>
</div>

Magento ERROR: unable to unpack

Share
Posted on September 7th, 2011 | Posted by admin

Current issue with PEAR repositories affects upgrade from Magento 1.4.1.1 to Magento 1.4.2.0 via Magento Connect Manager and installation of some Magento extensions. The following error (or similar one) is shown in Magento Connect Manager on installation/upgrade:

ERROR: unable to unpack downloader/pearlib/download/AW_Blog-1.0.21.tgz

To solve the issue it is needed to forcibedly upgrade PEAR package to the latest version using the following CLI command:

Magento shows blank/empty page. How do I solve this?

Share
Posted on September 7th, 2011 | Posted by admin

If you see a blank page opening your Store in browser, it indicates that there is a PHP syntax error somewhere in the code of your site. This usually happens when you modified files, templates or extensions manually, or installed a theme or magento extension with PHP syntax errors.

To see the actual error message you need to login via FTP to your Store and use the following instructions:

  • Download the index.php file to your computer
  • Edit the downloaded index.php file and uncomment (by removing leading hash character) the following code:
    ini_set('display_errors', 1);

    or insert this line somewhere at the top of the file.

  • Upload the modified index.php file back (you can also rename original index.php to index.php.orig to be able to revert the changes)
  • Refresh Magento Store page in your browser, you should see the PHP error message now
  • find the solution for specific error message

Please do not forget to change ‘display_errors’ setting back when the issue is solved.

Ajax Registration form in magento

Share
Posted on September 6th, 2011 | Posted by admin

In this article we are going to create a custom registration form in magento with Ajax functionality. The default magento registration form does the email verification of the user in the server side i.e After form submission. We are going to make it interactive.

Step 1: After creating the basic module,we need to override the default register.phtml and include our own template file. Magento has a built in prototype java script library support i.e prototype.js. In this example we are going to use Ajax with built in prototype.js library. The same result can also be achieved using jQuery but it requires a few more steps and also we need to write jQuery code to avoid conflicting with prototype library.

Step 2: We need a controller action for processing the client request through Ajax, it fetches the email address entered by user and it passes to the controller action. The controller action will check the email with the database and returns a message depending upon the condition.

Step 3: We need a place holder to display the result returned from the controller. Add your event in the email address field, once the email address is typed the email verification result has to be shown immediately to the user.

Magento cron job issue solution

Share
Posted on September 6th, 2011 | Posted by admin

Recently While developing a custom magento module with cron job i faced an issue, my cron job was not executed successfully. When i inspected the cron_schedule table in database it shows the status as error and the below message was found in messages field.
‘Mage_Core_Exception’ with message ‘Invalid callback: mymodel/observer::observermethod doesn’t exist
My model class is not recognized. But i have my observer class in the Model directory. I have my config.xml as below

<crontab>
<jobs>
<mycompany_modulename>
<schedule>
<cron_expr>*/5 * * * *</cron_expr>
</schedule>
<run>
<model>modulename/observer::methodcall</model>
</run>
</mycompany_modulename>
</jobs>
</crontab>