Pages

Wednesday, August 14, 2013

How to remove Shop by Options from the left bar in magento

In Catalog.xml

Please Comment following code
<!--<reference name="left"><block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
</reference>
-->

Sunday, August 11, 2013

To Change The Default Magento Logo

In ADMIN end
System -> Configuration->General->Design
Click on “Design” in the left side menu and open the “Header” section
Change the file name in the “Logo Image Src” to the file name you just uplaoded.Here you can also change the logo Alt message

Get Connection & Custom Query Execution in Magento

For database connection
$write = Mage::getSingleton('core/resource')->getConnection('core_write');

$qry=”Select * from tablename”;
$execute=$write->query($qry);
$fetch=$execute->fetch()
To get the Row Count
$count=$execute->rowCount();

Get Magento Urls in Phtml Page

Get Base Url :
Mage::getBaseUrl();
Get Store Url : 
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
Get Skin Url :
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
$this->getSkinUrl(‘images/imagename.jpg’);
Get Media Url :
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
Get Js Url : 
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
Get Current Url
Mage::helper(‘core/url’)->getCurrentUrl();
Get Home Url
Mage::helper(‘core/url’)->getHomeUrl();

Get Urls in Cms Pages or Static Blocks in Magento

Get Base Url :
{{store url=”"}}
Get Skin Url :
{{skin url=’images/imagename.jpg’}}
Get Media Url :
{{media url=’/imagename.jpg’}}
Get Store Url : 
{{store url=’mypage.html’}}

How to Call Magento Static Block in CMS Page and phtml in Magento

In PHTML
<?php echo $this->getLayout()->createBlock(‘cms/block’)->setBlockId(‘yourblockid’)->toHtml(); ?>
IN CMS
{{block type=”cms/block”  block_id=”yourblockid“}}

Get Top 10 Products in Magento

$collection= Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('*')
->setStoreId($storeId)
->addStoreFilter($storeId)

->setOrder(‘ordered_qty’, ’desc’)
->setPageSize(10) ;
foreach($collection as $product)
{
$name=$product->getName();
$productId=$product->getId();
$price=$product->getPrice();
}

Get Customer Details Using Customer Session in Magento

$customer = Mage::getSingleton(‘customer/session’)->getCustomer();
$email = $customer->getEmail(); // To get Email Address of a customer.
$firstname = $customer->getFirstname(); // To get Firstname of a customer.
$lastname= $customer->getLastname(); // To get Lastname of a customer.
$id =$customer->getId(); // To get Customer Id
//Get Details Using Customer Id
$customer = Mage::getModel(‘customer/customer’)->load($id)->getData();

Get Current Category Id in Magento

$layer = Mage::getSingleton(‘catalog/layer’);
$_category = $layer->getCurrentCategory();
$currentCategoryId= $_category->getId();

How do I remove Grid view or List view from my Magento store?

System->Configuration->Catalog->Frontend
You can change the List Mode.