Showing posts with label Frontend. Show all posts
Showing posts with label Frontend. Show all posts

Tuesday, August 28, 2012

Enable Search Engine Friendly URLs in Magento

To enable Search Engine Friendly URLs in Magento, you have to log in to the Magento admin area and click on the Configurations button. Under the System navigation menu, go to Web page from the sub-navigation panel on the left.

Click on the Search Engines Optimization tab and turn on the Use Web Server Rewrites (mark as Yes). Click on the Save Config button and your Magento SEF URLs will be enabled.

Saturday, August 25, 2012

Remove Estimate Shipping and Tax box

If you need to remove the Estimate Shipping and Tax from shopping cart page on magento, follow these instructions:

Open /app/design/frontend/YOUR_PACKAGE/YOUR_THEME/template/checkout/cart.phtml file

Find the line that mentions shipping

Delete it and save file.

Clear cache and refresh page to see result.

Friday, August 24, 2012

Magento Print Collection Query

There come several situations where you need to print the collection query in magento and here is the way how to print collection query:

Print Collection Query

$collection->printLogQuery(true);


Sunday, August 19, 2012

Moving magento from subdirectory to root directory

Moving magento from sub directory to root directory require following steps:

  1. Move all files from sub-directory to root directory
  2. Change .htaccess file code:
    Find RewriteBase /subdirectory/ to RewriteBase /
    where subdirectory is the name of your subdirectory e.g. magento
  3. Open phpMyAdmin and run these queries:
    update core_config_data set value='your new store url' where path = 'web/unsecure/base_url';
    update core_config_data set value='your new store url' where path = 'web/secure/base_url';
Note: your new store url must be a url i.e. http://google.com/ with trailing slash.

Friday, August 10, 2012

All products from a category

Here is the way to show all products from a specific magento category to home page.


{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="4" template="catalog/product/list.phtml"}}

Show All Products on Home Page

This is very common now a days to show all products on magento home page. Here is the code to achieve this:

{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}}

Thursday, August 9, 2012

Magento Display New Products on Home Page

There are many ways to show new products on home page but this is the simple way to display new products on home page.

{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}

Monday, August 6, 2012

URL is not accessible - Unable to read response, or response is empty

Sometimes during magento installation an error occurs saying "URL is not accessible - Unable to read response, or response is empty"

The simplest solution is to Click on "Skip Base URL Validation" and that test is ommitted at that point and it will work fine.

Wednesday, July 18, 2012

Add Product to Cart with Price Change

If you want to add a product to the cart after change its price, then you have to write an Observer that listens the checkout_cart_product_add_after or checkout_cart_update_items_after event. The code is same except checkout_cart_product_add_after is called for only one item and checkout_cart_update_items_after is called for all items in the cart.


/**
* @param Varien_Event_Observer $observer
*/
public function myDiscount(Varien_Event_Observer $observer)
{
$item = $observer->getQuoteItem();
if ($item->getParentItem()) {
$item = $item->getParentItem();
}

//discount 20% off
$discount = 0.20;

// Check if the discount isn't applied over and over while refreshing
$specialPrice = $item->getOriginalPrice() - ($item->getOriginalPrice() * $discount);

if ($specialPrice > 0) {
$item->setCustomPrice($specialPrice);
$item->setOriginalCustomPrice($specialPrice);
$item->getProduct()->setIsSuperMode(true);
}
}

Friday, May 18, 2012

Get Current Store Information

To get information about the current store in Magento


<?php
$store = Mage::app()->getStore();

//Get Current Store Name
$storeName = $store->getName();

//Get Current Store ID
$storeName = $store->getStoreId();

//Get Current Store Code
$storeName = $store->getCode();

//Get Current Store Website ID
$storeName = $store->getWebsiteId();

//Check if the current store is active
$storeName = $store->getIsActive();

//Get Current Store Home URL
$storeName = $store->getHomeUrl();

?>