Saturday 9 July 2011

Magento 'Shop By Brand' in SideBar

First create the template file and name it productbrand.phtml place it in catalog/product folder

copy the code given below and paster it in you productbrand.phtml

Note: Please chnage 'yourdomain.com' with your site domain name

<div>
<div>
<h4>
<span>Product Brands</span></h4>
</div>
<div style="padding-left:8px;">

<?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 id="manufacturer_list"><?php foreach ($manufacturers as $manufacturer): ?>
<li><a href="http://www.yourdomain.com/catalogsearch/advanced/result/?manufacturer[]=<?php echo $manufacturer['value'] ?>"><?php echo $manufacturer['label'] ?></a>
</li>
<?php endforeach; ?>   </ul>
</div>
<div>
</div>
</div>

Friday 8 July 2011

Create Customer By Code In Magento

Creating customer programmaticaly is easy just use the code below.

$websiteId = Mage::app()->getWebsite()->getId();
$store = Mage::app()->getStore();
 
//$customer = new Mage_Customer_Model_Customer();
$customer = Mage::getModel("customer/customer");
$customer->website_id = $websiteId; 
$customer->setStore($store);
 
$customer->firstname = "vikram";
$customer->lastname = "singh";
$customer->email = "singh@yourdomain.com";
$customer->password_hash = md5("password");
$customer->save();

Wednesday 6 July 2011

Change Admin URL In Magento

Its easy to change admin URL in Magneto, open local.xml at location below,
/app/etc/local.xml
now search for the code below

now replace 'admin' with your desired name.

as you do so your admin URL will be changed to adminarea

Magento Display Category BestSellers

 $curr_categoryid = Mage::registry('current_category')->getId();
$cat_Id= $curr_categoryid; 
 
$category = Mage::getModel('catalog/category')->load($cat_Id);
 
$products = Mage::getResourceModel('reports/product_collection')
        ->addOrderedQty()
        ->addAttributeToSelect('*')
        ->setOrder('ordered_qty', 'desc')
        ->addCategoryFilter($category);

Monday 4 July 2011

Display GrandTotal Of Shopping Cart in Magento

getQuote();
$total = $quote->getGrandTotal();
$total = $this->helper('checkout')->formatPrice($total); 

Remove Compare Products From Magento Sidebar

It is easy to remove compare products from magento sidebar. Just browser to location given below.
app/design/frontend/default/default/layout/catalog.xml
then search the tag below and remove it, compare products will be removed from magento sidebar