How to Display all products on homepage in Magneto

Today I will show you how to display all the products of a Magento store on its HomePage. This can be used also to display all the products on a particular page or maybe a custom Page.

Step 1: Login into your Magento Admin Dashboard;
Step 2: Go to: CMS -> Pages -> And choose Home Page;
Step 3: Now you must see the some edit options which will be applied for the HomePage.
Step 4: Go to: Contet Tab from left;
Step 5: Add following snippet in the WYSIWYG (As know as “What You See Is What You Get”);
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}}

Final: Now you must be able to see all the products on your homepage.

How to make a module to interact with database in magento

How to make a module in Magento to show data in front end.

Step 1:-

Go to your magento root directory   and create File’s and folders:-

1.       Create a xml configuration file in magento\app\etc\modules\Summer_Spring.xml.
2.       Create a namespace Folder under named “Summer” where “Summer” is namespace for our module magento\app\code\local\Summer.
3.       Create a Module folder under our namespace folder named with Spring so now we have module magento\app\code\local\Summer\Spring.
4.       Under our module we have to create five new folder’s  and relative files:-
 A)  etc/config.xml.
 B) controller/ IndexController.php     (controller name should start in lower case).
C)   Block/Index.php   (Block name should start in lower case).
D)  Helper / Data.php  Block name should start in lower case).
E)  Model/ Spring.php  Block name should start in lower case).
F)  Model/ Mysql4/ Spring.php
G)  Model/ Mysql4/ Spring/ Collection.php
5.       Under  Your theme section you have to create a config file For template. So create this file in magento\app\design\frontend\<Your theme package >\<Your theme>\layout\spring.xml
6.       Now create a folder in magento\app\design\frontend\<Your theme package >\<Your theme>\template\spring
7.       Now under “spring” create a file index.phtml
Ok now we have created all the files and folders for our Module. So let’s start coding
8.       First Open Summer_Spring.xml. and add the following code in this file and save it

How to show related product any where in magento

1. Copy and paste this code in your template page.

<!--- Code Start from here   -->

<div class="related_product"><?php $related_prods = $_product->getRelatedProductIds();foreach($related_prods as $related){   $_item = Mage::getModel('catalog/product')->load($related);    //echo $_rel->getName() . " " . $_rel->getSku();  ?>

Auto-Resize WordPress Featured Image

Auto-Resize WordPress Featured Image and Crop if Necessary

If you are creating a WordPress site for a user, you want to make sure everything is as easy as possible for them. One trick that can make things easier is to have images automatically resize when they are used for a featured image in WordPress. Resizing images may be easy for developers and graphic designers, but some end-users don’t have the skills or time to resize an image to fit perfectly in your design. Luckily, this is simple to set up.
 Steps
  1. Before we even start, make sure that your theme supports thumbnails. To do this just make sure the the following line of code is in your functions.php file.
add_theme_support( 'post-thumbnails' );
  1. The next step is to put the following line of code in the WordPress theme’s functions.php file.
add_image_size($name, $width, $height, $cropBoolean);
  1. The add_image_size(); function has 4 parameters. $name is the name that you want to call your image with. $width is the width you want the image to crop to in pixels. $height is the height you want the image to crop to in pixels. $cropBoolean is a true or false parameter. If set to true the image will crop itself automatically.
  2. In the example below, the name I use to call the cropped image is “featuredImageCropped”. The height and width are 250px and 200px respectively, and the image is set to crop.
add_image_size('featuredImageCropped', 250, 200, true);
  1. The next step is to reference the new image size in your theme. Place the following code wherever you would like to see your cropped image:
<?php the_post_thumbnail('featuredImageCropped'); ?>


Pagination In PHP

<?php
$page = 1;

if(isset($_GET['page'])){
$page=$_GET['page'];

}

$conn=mysql_connect('localhost','root','');
mysql_select_db('test',$conn);
$result_num_PerPage = 5;
$startResults = ($page - 1) * $result_num_PerPage;
$number_Of_Rows = mysql_num_rows(mysql_query('SELECT id FROM page',$conn));
$totalPages = ceil($number_Of_Rows / $result_num_PerPage);
$select = mysql_query("SELECT * FROM wp_usermeta LIMIT $startResults, $result_num_PerPage",$conn);