Magento themes and extensions

Simple way to Display Random Products in Magento

Share
Posted on December 12th, 2012 | Posted by admin

As a Magento programmer, sometimes we need to show random products in Magento. Here in this post I have provide you with simple Magento code for displaying random products within Magento template.

Below code will get random product using order(‘rand()’) and set product collection.

  1. <?php
  2. $collection = Mage::getResourceModel(‘catalog/product_collection’);
  3. Mage::getModel(‘catalog/layer’)->prepareProductCollection($collection);
  4. $collection->getSelect()->order(‘rand()’);
  5. $collection->addStoreFilter();
  6. $this->setProductCollection($collection);
  7. return parent::_beforeToHtml();
  8. ?>

How to display additional attributes in layered navigation in magento

Share
Posted on December 4th, 2012 | Posted by admin

How to display additional attributes in layered navigation in magento

This is the simple way to display additional attributes of products in layered navigation which helps to filter product easily.

Following are the steps to dislay additional attributes in layered navigation.

1) To add new attribute which you want to display in layered navigation

Go to catalog>attribute>manage attribute
click on add new attribute
now you can create attribute as your required name.But some fields are required as

How to Display the most recently added products first in magento 1.6.0.0

Share
Posted on February 15th, 2012 | Posted by admin

Magento Provides three different options to sort the catalog products i.e
name, price, position. For a store with more than 1000 products it is not
possible enter position values in backend for each products. We can replace
this with product ids , so that the frontend will display the most recently
added products.

Step 1: To Achieve this copy the file Toolbar.php from app/code/core/Mage/Catalog

/Block/Product/List/Toolbar.php. Create a Directory Structure in local and paste the Toolbar.php
as shown below

How to display Image Preview in Admin Form magento

Share
Posted on February 15th, 2012 | Posted by admin

Magento allows us to create custom form in admin panel by creating our own custom module. We can create almost any field in the admin form by creating a class that extends the base class Mage_Adminhtml_Block_Widget_Form. The _prepareForm method allows to define our form elements.
Sometimes we may need to upload a file in the adminform, the default file field doesn’t provide the image preview when we upload an image file. For this purpose we need to use image field type as shown in the below snippet

$fieldset->addField('filename', 'image', array(
'label' => Mage::helper('customform')->__('Image'),
'required' => false,
'name' => 'filename',
));

Taming magento errors display

Share
Posted on June 23rd, 2011 | Posted by admin

Taming magento errors display

Murphy says: “Anything that can go wrong, will go wrong”. When it happens to your store it’s best to get the information about it ASAP and present the error in the most humane possible way.

Since ever Magento presented it’s errors on the front-end for everyone to see and it was good for the developers but once the site has gone live that couldn’t be an option anymore. In Magento 1.4 those errors are now hidden and all your customer could get about the actual error was the “error number”.

Page 1 of 212»