Thursday, 26 December 2013

my account Login logout script in magento header

my account Login logout script in magento header


<?php
$loggedIn = $this->helper("customer")->isLoggedIn();
if($loggedIn == 1){ echo "<a href=\"".Mage::getBaseUrl()."customer/account/logout/\" />Logout</a>"; }
else{ echo "<a href=\"".Mage::getBaseUrl()."customer/account/\" />Login</a>"; }
?>

Show currency symbol in magento header

Show currency symbol in magento header

<?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); ?>


Thursday, 12 December 2013

Related product in view page in magento


Related product in view page in magento

Remove this line of code from catalog.xml
app/design/frontend/default/Your theme/layout/catalog.xml

<reference name="right">
<block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
</reference>

and add below line of code above the upsell xml bloxk in catalog.xml

<block type="catalog/product_list_related" name="catalog.product.related" as="related_products" before="-" template="catalog/product/list/related.phtml"/>

add this line of cade in view.phtml above upsell block:-

app/design/frontend/default/Your theme/template/catalog/product/view.phtml

<?php echo $this->getChildHtml('related_products') ?>

How to enable language switcher with flag images


How to enable language switcher with flag images

First open the page.xml
app/design/frontend/default/YOURTHEME/layout/page.xml

and add the below line of code under

replace this
<block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>

with
<block type="page/switch" name="store_language" as="store_language" template="page/switch/flags.phtml"/>
Now open the flags.phtml

app/design/frontend/default/YOURTHEME/template/page/switch/flags.phtml

replace this:-

<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<label for="select-language"><?php echo $this->__('Your Language:') ?></label>
<select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value" class="flags">
<?php foreach ($this->getStores() as $_lang): ?>
<?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
<option value="<?php echo $_lang->getCurrentUrl() ?>" style="background-image:url('<?php echo $this->getSkinUrl('images/flags/flag_'.$_lang->getCode().'.gif') ?>');"<?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>

with:-

<?php if(count($this->getStores())>1): ?>
<li class="flag-flag">
<div class="" style="float:left;">
<?php foreach ($this->getStores() as $_lang): ?>
<?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? 'active' : '' ?>
<div style="float:left;" class="<?php echo $_selected ?>">
<a class="flag" href="<?php echo $_lang->getCurrentUrl() ?>"><img src="<?php echo $this->getSkinUrl('images/flags/flag_'.$_lang->getCode().'.png')?>" /></a></div>

<?php endforeach; ?></div>
</li>
<?php endif; ?>

Flag images are put in skin/frontend/default/[your skin]/images/flags/

How to show cart sidebar in header in magento

How to show cart sidebar in header in magento


add this section in checkout.xml
app/design/frontend/default/YOURTHEME/layout/checkout.xml

<reference name="header">
<block type="checkout/cart_sidebar" name="cart_sidebar" as="topCart" template="checkout/cart/sidebar.phtml" before="-">
<action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
<block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">
<label>Shopping Cart Sidebar Extra Actions</label>
</block>
</block>
</reference>

like this :-

<reference name="right">
<block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-">
<action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
<block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">
<label>Shopping Cart Sidebar Extra Actions</label>
</block>
</block>
</reference>

add this line of code in header.phtml
app/design/frontend/default/fashion/template/page/html/header.phtml

<?php echo $this->getChildHtml('topCart'); ?>

Tuesday, 10 December 2013

Show product view count in product page in magento

Show product view count in product page in magento

add below line of code in view page:-
app/design/frontend/default/your theme/template/catalog/product/view.phtml

<?php

$id = $id=$_helper->productAttribute($_product, $_product->getId(), 'id');

$fromDate = '2013-12-10';
$toDate   = now();
$viewedProducts = Mage::getResourceModel('reports/product_collection')->addViewsCount($fromDate, $toDate);
foreach($viewedProducts as $product) {
if($product->getData('entity_id')==$id)
{
    echo  "Total View Count: " . $product->getData('views');
}}
?>


You are done!!!!

Show product wish-list count in product page in magento

Show product wish-list count in product page in magento:-

Add below line of code in view page:-

app/design/frontend/default/your theme/template/catalog/product/view.phtml

<?php
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$productid = $_product->getId();
$total_wishlist = $readConnection->fetchCol("SELECT count(*) FROM wishlist_item where product_id = '$productid' ");
                                           
echo 'whishlist count:'.$total_wishlist['0'];
?>


You are done!!!

Monday, 9 December 2013

Add to cart button on upsell product page in magento

Add to cart button on upsell product page in magento

Add to cart button in upsell product page

to add "add to cart" button on upsell product page please open the upsell.phtml page:-

app/design/frontend/default/your theme/template/catalog/product/list/upsell.phtml


add below line of code in related .phtml page:-

<form action="<?php echo $this->getAddToCartUrl($_link) ?>" method="post" id="product_addtocart_form_<?php echo $_link->getId()?>"<?php if($_link->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
          <?php if(!$_link->isGrouped()): ?>
          <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo ($this->getMinimalQty($_link)?$this->getMinimalQty($_link):20) ?>" />
          <label for="qty"><?php echo $this->__('Qty') ?>:</label>
          <?php endif; ?>
          <button type="button" onclick="this.form.submit()"><span><span><span><?php echo $this->__('Add to Cart') ?></span></span></span></button>
        </form>
Your are Done!!!!!!!!!!!!!!

Add to cart button in related product page in magento

Add to cart button in related product page in magento

to add "add to cart" button on related product page please open the related.phtml page:-

app/design/frontend/default/your theme/template/catalog/product/list/related.phtml


add below line of code in related .phtml page:-

<form action="<?php echo $this->getAddToCartUrl($_item) ?>" method="post" id="product_addtocart_form_<?php echo $_item->getId()?>"<?php if($_item->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>

 <?php if(!$_item->isGrouped()): ?>
  <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo ($this->getMinimalQty($_item)?$this->getMinimalQty($_item):1) ?>" />

  <label for="qty"><?php echo $this->__('Qty') ?>:</label>

 <?php endif; ?>

 <button type="button" onclick="this.form.submit()"><span><span><span><?php echo $this->__('Add to Cart') ?></span></span></span></button>
 </form>

Your are Done!!!!!!!!!!!!!!

Wednesday, 25 September 2013

Show category name in breadcrumb in magento

Show category name in breadcrumb in magento when click on home page product

Just add the below code in top of the breadcrumbs.phtml page :-

<?php
if ($product = Mage::registry('current_product')) {
    $categories = $product->getCategoryCollection()->load();

    if($categories) {
        foreach ($categories as $category)
        {
            if($category) {
            $category = Mage::getModel('catalog/category')->load($category->getId());
            break;
            }
        }
    }
    $lastCrumbName = $product->getName();
    $lastCategoryAdjust = 0;
   
}
else {
    if($category = Mage::registry('current_category')) {
    $lastCrumbName = $category->getName();
    }
    $lastCategoryAdjust = 1;
}

if($category) {
    if($path = $category->getPath()) {
        $path = explode('/', $path);
        $crumbs = array('home' => array('label' => 'Home',
        'title' => 'Home',
        'link' => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB),
        'first' => true,
        'last' => false
        ));
        for($i = 2; $i < count($path) - $lastCategoryAdjust; $i++) {
            $cur_category = Mage::getModel('catalog/category')->load($path[$i]);
            if($cur_category && $cur_category->getIsActive()) {
                $crumbs['category' . $path[$i]] = array('label' => $cur_category->getName(),
                'title' => $cur_category->getName(),
                'link' => $cur_category->getUrl(),
                'first' => false,
                'last' => false
                );
            }
        }
          $crumbs['current'] = array('label' => $lastCrumbName,
        'title' => '',
        'link' => '',
        'first' => false,
        'last' => true
        );
    }
}

?>

You are done!!!!!

How to get category id from product id in magento

How to get category id from product id in magento

<?php
$product = Mage::getModel('catalog/product')->load(6);

$cats = $product->getCategoryIds();
foreach ($cats as $category_id) {
    $_cat = Mage::getModel('catalog/category')->load($category_id) ;
    echo $_cat->getName();
}
?>

Thursday, 19 September 2013

Extension Key for installed the usefull extenion in magento


Extension Key:-
http://connect20.magentocommerce.com/community/Mage_Productlist
http://connect20.magentocommerce.com/community/Crius_SkipStep1
http://connect20.magentocommerce.com/community/magento_easy_tabs
http://connect20.magentocommerce.com/community/Facebook_LikeBox
http://connect20.magentocommerce.com/community/Custom_Layered_Navigation
http://connect20.magentocommerce.com/community/AjaxCart
http://connect20.magentocommerce.com/community/EM_Quickshop
http://connect20.magentocommerce.com/community/Squirreltechnologies_Squeeqly
http://connect20.magentocommerce.com/community/easy_exploded_menu
http://connect20.magentocommerce.com/community/AGCloudRolloverToZoom

Saturday, 8 June 2013

Speed up magento site performance

Optimizing Magento Site Performance

This is a guide for optimizing Magento performance. Most optimizations can be performed on any version of Magento. Those intended for specific versions and newer will be indicated.

The default .htaccess file that comes with Magento has several sections dealing with performance. These configurations are commented out and will need to be turned on to realize their benefit.

Please backup the .htaccess file and do the given changes.

Enable Output Compression

This section will turn on the apache mod_deflate module, which compresses text, css, and javascript before it is sent to the browser. This results in a smaller download size. To enable, simply uncomment the appropriate lines so that it looks like the following:
 
<IfModule mod_deflate.c>

############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip

    # Insert filter on all content
    SetOutputFilter DEFLATE
    # Insert filter on selected content types only
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript 

    # Netscape 4.x has some problems...
    BrowserMatch ^Mozilla/4 gzip-only-text/html

    # Netscape 4.06-4.08 have some more problems
    BrowserMatch ^Mozilla/4\.0[678] no-gzip

    # MSIE masquerades as Netscape, but it is fine
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    # Don't compress images
    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

    # Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary

</IfModule>

Enable Expires Headers

  • NOTE: This does not work on Litespeed servers.
Browsers use Expires headers to determine how long a page component can be cached. Static components, like images, should have far-future expires headers, but truthfully, all page components should have expires headers. To turn this feature on, just uncomment the appropriate line and add "ExpiresActive On" right above it. See below:

<IfModule mod_expires.c>

############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires

    ExpiresActive On
    ExpiresDefault "access plus 1 year"

</IfModule>

Disable ETags

ETags are a way for browsers to validate cached components across subsequent visits. They can slow down a site served from a cluster if the cluster hasn't implemented them properly. It is best to just turn them off as follows:
 
############################################
## If running in cluster environment, uncomment this
## http://developer.yahoo.com/performance/rules.html#etags

    FileETag none

Magento Admin Tweaks

There are a couple of features that can be enabled in the back end of Magento to optimize performance. Generally, these features are available on versions 1.4.0.1 and higher and should be performed when most of the development work is done.

Combine CSS and JS Files

This feature reduces the number of HTTP requests. For versions earlier than 1.4.x, the Fooman_Speedster extension can be used instead.
  1. In the Magento Admin, go to System > Configuration > Developer.
  2. Under "Javascript Settings", change "Merge Javascript Files" to YES.
  3. Under "CSS Settings", change "Merge CSS Files" to YES.
  4. Clear the cache.

Enable Flat Catalog

Magento uses the EAV model to store customer and product data. This enables these objects to be incredibly extensible, but results in longer SQL queries and more reads. Enabling the Flat Catalog for Categories and Products merges product data into one table, thereby improving performance. Generally, all stores should enable Flat Catalog for Categories. Stores with over 1000 products should enable Flat Catalog for Products.
  1. In the Magento Admin, go to System > Configuration > Catalog.
  2. Under "Frontend", change "Use Flat Catalog Category" to YES.
  3. Under "Frontend", change "Use Flat Catalog Product" to YES. (optional)
  4. Clear the cache.

Enable the Magento Compiler

Magento's application files are searched for in the following order:
  • app/code/local
  • app/code/community
  • app/code/core
  • lib
This search is performed for every page load, every time, resulting in a lot of filesystem reads. The Mage_Compiler reduces the number of reads by copying all of the application files to a single include directory. It also caches the most frequently used pages.
  1. In the Magento Admin, go to System > Tools > Compilation.
  2. Click "Run Compilation Process"

Other Performance Tweaks

Parallelize Downloads

Most browsers limit the number of concurrent connections to a domain to four. If your page has a lot of components coming from the same domain, this can result in a longer page load time. You can trick the browser into grabbing more components by using different subdomains for static components. This is as simple as creating pointer domains in Siteworx. However, due to the way that Nexcess configures the subdomain logic in the Vhost file, an additional modification is necessary to make this work on our servers.
  1. Create Pointer domains in Siteworx.
    • This can be a single "static.example.com", or separate "js.example.com", "media.example.com", and "skin.example.com" domains.
  2. Once they are resolving, change the media, js, and skin URLs in Magento as follows:
  3. Edit the Vhost file so that apache doesn't try to load the sub-directories ../media, ../skin, or ../js, but rather the web root itself. Directly below the following lines:
    NOTE: If you are on a Managed or Shared server, please open a ticket with support@nexcess.net for assistance with this.
      # subdomain logic
      RewriteEngine On
      RewriteOptions inherit
      RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
      RewriteCond %{HTTP_HOST} !^example\.com [NC]
    
    Add:
    
      RewriteCond %{HTTP_HOST} !^js\.example\.com [NC]
      RewriteCond %{HTTP_HOST} !^media\.example\.com [NC]
      RewriteCond %{HTTP_HOST} !^skin\.example\.com [NC]
  4. Save the file and restart Apache.
  5. Clear the cache and reload the page to make sure the static content is coming from the new URLs.


    Other Way to Speed Up Magento Site Performance

    Speed up Magento with these simple admin settings

    Please Follow the below general Steup to Speed up your magento Store

    1. Enable cache

    Most users are well aware of this one ;) .
    Just navigate to System > Cache Management and enable all cache types.
    Magento Cache Management
    Magento Cache Management

    2. Re-index data

    Regularly indexing Magento data will also have some impact on performance.
    Under System > Index Management select all indexes and hit the “Reindex Data” submit button.
    Magento Index Management
    Magento Index Management

    3. Enable JavaScript file merging

    Combining all JavaScript files into one will greatly reduce the number of HTTP requests your Magento site makes to the server and will have a nice impact on speed.
    Navigate to System > Configuration > Developer > JavaScript Settings and select “Yes” under “Merge JavaScript Files”.
    Combine All JavaScript Files
    Combine All JavaScript Files

    4. Combine CSS files

    Like with JavaScript files, combining all CSS files into one will reduce load time and increase speed. Magento also has an admin setting for that but we don’t recommend turning it – it is much better to use Ultimento’s Magento themes which are truly optimized for speed. In Ultimento there is only 1 combined CSS file that is also compressed and minified.
    If you’re not running Ultimento, you can combine all CSS files into one via the Magento admin:
    Go to System > Configuration > Developer > CSS settings and select “Yes” for “Merge CSS Files”.
    Combine All CSS Files
    Combine All CSS Files

    5. Turn off the logs

    On a production Magento installation make sure all logs are turned off!
    The settings are under System > Configuration > Developer > Log Settings.
    Magento Log
    Magento Log

    6. Enable the compilation

    Magento’s compilation is a great tool to speed up a production installation.
    Go to System > Tools > Compilation and hit “Run Compilation Process”.
    Magento Compilation
    Magento Compilation

    Of course there’s many other things besides these admin settings you can do to speed up your Magento store!

Tuesday, 30 April 2013

Useful Free Magento Extension


All free Magento Extension

http://www.magentocommerce.com/magento-connect/product-sold-count-9033.html

http://www.mage-shop.com/product-video-extension.html
demo url:-http://demo.mage-shop.com/blackberry-8100-pearl.html


http://www.magentocommerce.com/magento-connect/product-video-8703.html
http://www.magentocommerce.com/magento-connect/product-sold-count-9033.html
http://www.indieswebs.com/magento-product-video.html

http://www.magentocommerce.com/magento-connect/ajax-add-to-cart-2992.html

http://www.magentocommerce.com/magento-connect/vs-ajax-add-to-cart-add-to-wishlist-add-to-compare-paging-toolbar.html

http://ecommerce.aheadworks.com/free-stuff/video-module-community-edition.html

http://www.magentocommerce.com/magento-connect/search-autocomplete-and-suggest-widget-free-by-searchanise.html
http://www.magentocommerce.com/magento-connect/m-turbo-e-commerce-accelerator-6027.html

***********************manage Price format extension********************************
***********************easy tabing extension************************************
***********************Quick login extension************************************* **
***********************Free shop by brand******************* **********************
***********************customer-activation extension*********************************
***********************product out of stock subscription extension**********************

*********************best seller extension****************** ***********************

***********************exact search extension******************************

*******************advance compare extension****************** *****************

***********************login only extension****************** **********************

*********************add custom field in checkout extension****************** ********

***********************facebook like button extension****************** **************
*******************Pintrest button extension****************** *******************
***********************Customer order comment extension****************** **********
***********************Easy PDF Invoice***************************** *************

***********************Side banner extension***************************** **********

***********************Quick contact extension********************************

http://www.magentocommerce.com/magento-connect/catalog/product/view/id/16142/s/quick-contact-form-3533/

***********************Cart Dropdown extension********************************

http://www.magentocommerce.com/magento-connect/sharplogicians-cart-drop-down-3832.html

***********************Zoom image extension******************************

http://www.magentocommerce.com/magento-connect/vs-featurezoom.html

***********************Related product slider******************************

http://www.magentocommerce.com/magento-connect/catalog/product/view/id/16454/s/related-product-slider-5017/

***********************Featured product slider******************************

http://www.magentocommerce.com/magento-connect/catalog/product/view/id/16535/s/featured-products-4253/

***********************Featured product extension******************************

http://www.magentocommerce.com/magento-connect/magefeaturedproduct.html

*********************** product slider extension******************************

*********************** product slider extension******************************

*********************** facebook login******************************

*********************** Offline maintenance msg extension******************************

*************************** ****************************
*********This extension disables the default Customer registration in your Magento store.****

Upgrade mageto version to latest version:-

*************************************testimonial*********************

Paid Extension
***********************Quick login extension************************************* **

***********************Product slider extension****************** *******************

*******************************Now not Available************************************

Important Blog Link
**************forget password xml chnages****************************
http://www.magentocommerce.com/boards/viewthread/267435/

***********************Go daddy solution link******************************


How to remove decimal from price in magento


Hello Magento Developer,

To change the price from $100.00 to $100 for example.
For this, you need to edit code/core/Mage/Directory/Model/Currency.php
  • Open code/core/Mage/Directory/Model/Currency.php
  • Find the following :-
public function format($price, $options=array(), $includeContainer = true, $addBrackets = false)
{
return $this->formatPrecision($price, 2, $options, $includeContainer, $addBrackets);
}
on line no 195

change this code to:-
public function format($price, $options=array(), $includeContainer = true, $addBrackets = false)
{
return $this->formatPrecision($price, 0, $options, $includeContainer, $addBrackets);
}

0 – Denotes the digit after decimal point in price..
Now Clear the cache properly.
For Clear the Cache.
- Go to System –> Cache Management
- Refreh Cache.

Saturday, 13 April 2013

show brand on list page

<?php
    $product = Mage::getModel('catalog/product');
    $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
    ->setEntityTypeFilter($product->getResource()->getTypeId())
    ->addFieldToFilter('attribute_code', 'manufacturer');
    $attribute = $attributes->getFirstItem()->setEntity($product->getResource());
    $manufacturers = $attribute->getSource()->getAllOptions(false);
?>


<ul>

  <?php foreach ($manufacturers as $manufacturer): ?>
  <?php  $bid = $manufacturer['value']; ?>
<?php /*?><li><a href="<?php echo $currentUrl ?>?manufacturer=<?php echo $manufacturer['value'] ?>"><?php echo $manufacturer['label'] ?><?php echo $manufacturer['value'] ?></a></li><?php */?>

<?php
$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToFilter('manufacturer', array('in' => array($bid)));
$products->addAttributeToSelect('*');
$products->load(); ?>

<li><?php echo $manufacturer['label'] ?>(<?php echo $products->count() ?>) </li>   
  

<ul class="brand-products">
<?php
$i = 0;
foreach($products as $_prod)
{       
    echo $_cat_name = $_prod->getCategory(); ?>
   
    <li>
    <a href="<?php echo $_prod->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_prod, 'small_image'), null, true) ?>" class="product_img_link"><img src="<?php echo $this->helper('catalog/image')->init($_prod, 'small_image')->resize(200); ?>" width="200" height="200" alt="<?php echo $this->stripTags($this->getImageLabel($_prod, 'small_image'), null, true) ?>" />
    <a href="<?php echo $_prod->getUrlPath() ?>"><?php echo $_prod->getName()?>
     <?php echo $_cat_name; ?></a>       
   <span class="price"><?php echo $_prod->getFormatedPrice()?></span>
  
   </li>  
<?php } ?>
</ul>


  <?php endforeach; ?>
</ul>



<?php /*?><select class="choose-sel" name="computer_manufacturers" id="brand_name" onchange="submit();">
  <option value="select">choose your brand</option>
  <?php foreach ($manufacturers as $manufacturer): ?>
      <option value="<?php echo $manufacturer['value'] ?>"><a href="<?php echo $currentUrl ?>?manufacturer=<?php echo $manufacturer['value'] ?>"><?php echo $manufacturer['label'] ?></a></option>
  <?php endforeach; ?>
</select><?php */?>

<?php /*?><?php
$bid = 5; // the brand / manufacturer ID


$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToFilter('manufacturer', array('in' => array($bid)));
$products->addAttributeToSelect('*');
$products->load();    
    echo $products->count() ?>

<ul class="brand-products">
<?php
$i = 0;
foreach($products as $_prod)
{       
    echo $_cat_name = $_prod->getCategory(); ?>
   
    <li>
    <a href="<?php echo $_prod->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_prod, 'small_image'), null, true) ?>" class="product_img_link"><img src="<?php echo $this->helper('catalog/image')->init($_prod, 'small_image')->resize(200); ?>" width="200" height="200" alt="<?php echo $this->stripTags($this->getImageLabel($_prod, 'small_image'), null, true) ?>" />
    <a href="<?php echo $_prod->getUrlPath() ?>"><?php echo $_prod->getName()?>
     <?php echo $_cat_name; ?></a>       
   <span class="price"><?php echo $_prod->getFormatedPrice()?></span>
  
   </li>  
<?php } ?>
</ul><?php */?>

showproduct on conditional bsae

<?php $cats = Mage::getModel('catalog/category')->load(2)->getChildrenCategories(); ?>

<ul>
  <?php foreach($cats as $category): ?>
  <?php $category_id = $category->getId() ?>
  <?php $count = Mage::getModel('catalog/category')->load($category_id)->getProductCount(); ?>
 
 
  <?php if($count > 0): ?>
 
  <li><a href="<?php echo $category->getUrl() ?>"><?php echo $category->getName() ?> </a>
    <?php $category_id = $category->getId() ?>
    (<?php echo $count = Mage::getModel('catalog/category')->load($category_id)->getProductCount(); ?>)
    <?php $catagory_model = Mage::getModel('catalog/category')->load($category_id); //where $category_id is the id of the category ?>
    <?php 
    $collection = Mage::getResourceModel('catalog/product_collection');
    $collection->addCategoryFilter($catagory_model); //category filter
    $collection->addAttributeToFilter('status',1); //only enabled product
    $collection->addAttributeToSelect(array('name','url','small_image','price','special_price','description','short_description')); //add product attribute to be fetched
    //$collection->getSelect()->order('rand()'); //uncomment to get products in random order   
    $collection->addStoreFilter();    
   
    if($count > 0)
    { ?>
    <table>
      <tr>
     
      <?php
    $z=1;
    foreach ($collection as $_product): ?>
      <td><table>
          <tr>
            <td><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product_img_link"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(200); ?>" width="200" height="200" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a></td>
          </tr>
          <tr>
            <td><a href="<?php echo $_product->getProductUrl() ?>"><?php echo $_product->getName(); ?></a></td>
          </tr>
          <tr>
          <tr>
            <td><?php $_pci = $this->htmlEscape($_product->getPrice());
    echo number_format($_pci,2); ?>
            </td>
          </tr>
          <td><?php $_splprice = $_product->getSpecialPrice(); //get Product's Special price
    if(!$_splprice==''){
    echo number_format($_splprice,2); } ?></td>
          </tr>
          <tr>
            <td><?php echo $_product->getShortDescription(); //get product's short description ?></td>
          </tr>
          <tr>
            <td><?php echo $_product->getDescription(); //get Product's Long Description ?></td>
          </tr>
          </tr>
        </table>
        <?php /*?><?php echo $_product->getId(); ?><?php */?>
        <?php //echo Mage::getBaseUrl(); ?>
        <?php if($_product->isSaleable()): ?>
        <?php /*?><p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p><?php */?>
        <p>
          <button onclick="setLocation('<?php echo Mage::getBaseUrl(); ?>checkout/cart/add?product=<?php echo $_product->getId(); ?>&qty;=1')" class="button btn-cart"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
        </p>
        <?php else: ?>
        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
        <?php endif; ?>
      </td>
      <?php if($z%3==0){?>
      </tr>
     
      <tr>
        <?php } $z++; ?>
        <?php endforeach; ?>
      </tr>
    </table>
    <?php } else { ?>
    <table>
      <tr>
        <td><?php echo 'No products Assigned in this Category'; ?> </td>
      </tr>
    </table>
    <?php } ?>
  </li>
  <?php endif; ?>
  <?php endforeach; ?>
</ul>

show product according to category in cms page

<?php $cats = Mage::getModel('catalog/category')->load(2)->getChildrenCategories(); ?>

<ul>
<?php foreach($cats as $category): ?>
    <li><a href="<?php echo $category->getUrl() ?>"><?php echo $category->getName() ?> </a>
    <?php $category_id = $category->getId() ?>
   
    (<?php echo $count = Mage::getModel('catalog/category')->load($category_id)->getProductCount(); ?>)
   
    <?php $catagory_model = Mage::getModel('catalog/category')->load($category_id); //where $category_id is the id of the category ?>   
   
<?php 
    $collection = Mage::getResourceModel('catalog/product_collection');
    $collection->addCategoryFilter($catagory_model); //category filter
    $collection->addAttributeToFilter('status',1); //only enabled product
    $collection->addAttributeToSelect(array('name','url','small_image','price','special_price','description','short_description')); //add product attribute to be fetched
    //$collection->getSelect()->order('rand()'); //uncomment to get products in random order   
    $collection->addStoreFilter();    
   
    if($count > 0)
    { ?>
<table>
    <tr>
   
    <?php
    $z=1;
    foreach ($collection as $_product): ?>
   
    <td>
   
   
    <table>
    <tr>
    <td><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product_img_link"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(200); ?>" width="200" height="200" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a></td>
    </tr>
    <tr>
    <td><a href="<?php echo $_product->getProductUrl() ?>"><?php echo $_product->getName(); ?></a></td>
    </tr>
    <tr>
    <tr>
    <td><?php $_pci = $this->htmlEscape($_product->getPrice());
    echo number_format($_pci,2); ?>
    </td>
    </tr>
    <td><?php $_splprice = $_product->getSpecialPrice(); //get Product's Special price
    if(!$_splprice==''){
    echo number_format($_splprice,2); } ?></td>
    </tr>
    <tr>
    <td><?php echo $_product->getShortDescription(); //get product's short description ?></td>
    </tr>
    <tr>
    <td><?php echo $_product->getDescription(); //get Product's Long Description ?></td>
    </tr>
    </tr></table>
    <?php /*?><?php echo $_product->getId(); ?><?php */?>
    <?php //echo Mage::getBaseUrl(); ?>
   
    <?php if($_product->isSaleable()): ?>
   
    <?php /*?><p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p><?php */?>
   
   
    <p><button onclick="setLocation('<?php echo Mage::getBaseUrl(); ?>checkout/cart/add?product=<?php echo $_product->getId(); ?>&qty;=1')" class="button btn-cart"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
                    <?php else: ?>
                        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                    <?php endif; ?>
   
   
   
    <?php /*?><?php //echo $_product->getFinalPrice(); ?>
    <?php //echo $_product->getSpecialPrice(); ?>   
    <?php //echo $_product->getPrice(); ?>
    <?php //echo $this->htmlEscape($_product->getName()); ?>
    <?php echo $this->htmlEscape($_product->getPrice()); ?>
    <?php echo $this->htmlEscape($_product->getSpecialPrice()); ?>
   
   
    <?php
   
//echo $_product->getName();  // get Product's name

echo $_product->getShortDescription(); //get product's short description

echo $_product->getDescription(); //get Product's Long Description

//echo $_product->getPrice();  //get Product's Regular Price

echo $_product->getSpecialPrice(); //get Product's Special price

//echo $_product->getProductUrl(); //get Product's Url

//echo $_product->getImageUrl(); //get Product's image Url
       
    ?><?php */?>
   
    </td>
    <?php if($z%3==0){?>
    </tr>
    <tr>
      <?php } $z++; ?>
    <?php endforeach; ?>
    </tr>
</table>
       
       
        <?php } else { ?>
        <table>
    <tr><td>
   
    <?php echo 'No products Assigned in this Category'; ?>
   
    </td></tr></table>
       
        <?php } ?>
       
    </li>
<?php endforeach; ?>
</ul>


 <?php /*?>****************************************

<?php 
$product = Mage::getModel('catalog/product');
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'manufacturer');
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$manufacturers = $attribute->getSource()->getAllOptions(false);
?>


<?php foreach ($manufacturers as $manufacturer)

{ ?>

<?php echo Mage::getBaseUrl(); ?>catalogsearch/advanced/result/?manufacturer[]=$manufacturer['value'];



<?php echo Mage::getBaseUrl(); ?>catalogsearch/advanced/result/?manufacturer[]=$manufacturer['label'];

<?php } ?>

 ****************************************

<?php


    $product = Mage::getModel('catalog/product');
    
    $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
        ->setEntityTypeFilter($product->getResource()->getTypeId())
        ->addFieldToFilter('attribute_code', 'manufacturer') // This can be changed to any attribute code
        ->load(false);
    
    $attribute = $attributes->getFirstItem()->setEntity($product->getResource());
    
   
    $manufacturers = $attribute->getSource()->getAllOptions(false);
    foreach ($manufacturers as $manufacturer)
    {
    echo $manufacturer;
    }

 ?>
  ****************************************


<?php
 $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'manufacturer');

foreach ( $attribute->getSource()->getAllOptions(true, true) as $option)
{
     $attributeArray[$option['value']] = $option['label'];


    foreach($attributeArray as $key=>$val)
    {
    echo $val;
   
    } ?>
   
     ****************************************
   
    <?php
    $attribute = Mage::getModel('eav/entity_attribute')
                ->loadByCode('catalog_product', 'manufacturer');

$valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
            ->setAttributeFilter($attribute->getData('attribute_id'))
            ->setStoreFilter(0, false);

$preparedManufacturers = array();           
foreach($valuesCollection as $value) {
    $preparedManufacturers[$value->getOptionId()] = $value->getValue();
}  


if (count($preparedManufacturers)) {
    echo "<h2>Manufacturers</h2><ul>";
    foreach($preparedManufacturers as $optionId => $value)
    {
        echo "<li>" . $value . " - (" . $optionId . ")</li>";
       
    }
    echo "</ul>";
}


 ?>

 ****************************************




<?php

$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'manufacturer');
foreach ( $attribute->getSource()->getAllOptions(true, true) as $option)
{
$attributeArray[$option['value']] = $option['label'];
}


$attributes = Mage::getModel('catalogsearch/advanced')->getAttributes();
$attributeArray=array();
foreach($attributes as $a)
{
if($a->getAttributeCode() == 'manufacturer')
    { ?>
    <table><tr>
    <?php foreach($a->getSource()->getAllOptions(false) as $option)
        { ?>
        <td><?php echo $attributeArray[$option['value']] = $option['label']; ?></td>
       
    <?php     } ?>
   
    </tr></table>
    <?php }
}

 ?>
 <?php */?>

  <?php /*?><?php foreach ($manufacturers as $manufacturer): ?>
    <a href="<?php echo $manufacturer->getUrl() ?>"><?php echo $this->htmlEscape($manufacturer->getManufacturer()) ?></a><br />
    <?php endforeach ?>
    </div>
    <?php if ($this->getTotal() > count($manufacturers)): ?>
    <div class="actions"><a href="<?php echo Mage::helper('aitmanufacturers')->getManufacturersUrl() ?>" title="<?php echo $this->__('Full list of Brands')?>"><?php echo $this->__('More...')?></a></div>
    <?php endif ?> <?php */?>