Friday, 6 July 2012

How to Call Newsletter in footer in Magento

To show Newsletter in footer go toapp/design/frontend/default/YourTheme/layout/newsletter.xml and add the following lines in default

<reference name="footer">
<block type="newsletter/subscribe" name="footer.newsletter" 
template="newsletter/subscribe.phtml"/>
  reference>

and add the following line inapp/design/frontend/default/YourTheme/template/page/html/footer.phtml 

 echo $this->getChildHtml('footer.newsletter'); ?>

Display special priced products on your Magento homepage

Step one
Open your homepage CMS page and click on the design tab. Paste the following:





9

 
Step two:
 
First of all this is the code were that we're going to be using to do this.
 
Mage::getSingleton('core/session', array('name' => 'frontend'));
$_productCollection = Mage::getResourceModel('catalogsearch/advanced_collection')
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
->addMinimalPrice()
->addStoreFilter();

Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($_productCollection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($_productCollection);

$todayDate = date('m/d/y');
$tomorrow = mktime(0, 0, 0, date('m'), date('d'), date('y'));
$tomorrowDate = date('m/d/y', $tomorrow);

$_productCollection->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate))
->addAttributeToFilter('special_to_date', array('or'=> array(
0 => array('date' => true, 'from' => $tomorrowDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left');


echo '
';
$_collectionSize = $_productCollection->count();
$i=0; foreach($_productCollection as $_product):
if($i++%3==0)
echo '
    ';

    echo '
  1. ';
    echo '
    ';
    echo '';
    echo ''.$this->htmlEscape($this->getImageLabel($_product, 'small_image')).'
    ';
    echo '
    '.$this->htmlEscape($_product->getName()).'
    ';

    echo $this->getPriceHtml($_product, true) ?>




 

You can then paste this into a file and name it specials.phtml and save it into your frontend template folder catalog/product.

How To Show Size Chart in Magento Detail Page


CREATE MAGENTO SIZE CHARTS USING STATIC BLOCKS AND JAVASCRIPT

In my Old post I showed you how to create a size chart using a
link that pop-ups an external php page. 
In this tutorial, I will show you how to use static blocks and JavaScript to create size charts .Demo Here 
Suppose you want to create a size chart for the product type Jackets.
Here are steps you have to follow:
  • STEP 1: Create a new static block called "Jackets Size Chart" identified by "jackets-size-chart"
  • STEP 2: Create a new attribut called size_chart_template

STEP 1

 

STEP 2

Go to Admin->Attributes->Manage Attributes
Add new attribute with the following properties: 
  • Attribute Code : size_chart_template
  • Scope: Global
  • Catalog Input type  for Store Owner : Dropdown
  • Unique Value : No
  • Required value : No
  • Input Validation for store owner: No
  • Apply to * : All Product Types
  • Use to create Configurable Product   : No
For Frontend Properties: No everywhere and Position to 0
In Manage Label/Options:
Admin : Size Chart Template
add your options for example:
jackets-size-chart (remember this is the identifier of your static block)
...
Save your attribute.
Now go to Catalog->Attributes->Manage Attribute Sets
Select your set and add the attribute you have just created. (drag and drop)
Now we are going to assign to the product  Icon Retro Motorcycle Jacket, the size chart identified by "jackets-size-chart".
Go to Icon Retro Motorcycle Jacket Item and select "jackets-size-chart" from your dropdown list (You should add this attribut before use it).
Open app/design/frontend/default/yourtemplate/template/catalog/product/view.phtml and paste the following code. (where you like to see your size chart info)
1  
2
3  $sizeChartIcon= Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."size-charts/size-chart.gif"; ?>
5            
"size-chart" style="display:none;"> echo Mage::app() ->getLayout() ->createBlock('cms/block') ->setBlockId($_product->getAttributeText('size_chart_template')) ->toHtml(); ?>
6

skip shipping method from onepage checkout :=>In Magento

skip shipping method from onepage checkout :=>In Magento 

step 1: app/code/core/Mage/Checkout/Block/Onepage/Onepage.php

change the line
$stepCodes = array('billing', 'shipping', 'shipping_method', 'payment', 'review'); 
with
$stepCodes = array('billing', 'payment', 'review');

step2 : app/code/core/mage/checkout/controller/Onepagecontrollers.php 

protected $_sectionUpdateFunctions = array(
'payment-method' => '_getPaymentMethodsHtml',
'shpping-method' => '_getShippingMeghtoHtml',
'review' => '_getReviewHtml',
);

to 

protected $_sectionUpdateFunctions = array(
'payment-method' => '_getPaymentMethodsHtml',
'review' => '_getReviewHtml',
);


Step 3. In same page

------------------------Change this code--------------------------
public function saveBillingAction()
{
if ($this->_expireAjax()) {
return;
}
if ($this->getRequest()->isPost()) {
$postData = $this->getRequest()->getPost('billing', array());
$data = $this->_filterPostData($postData);
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);

if (isset($data['email'])) {
$data['email'] = trim($data['email']);
}
$result = $this->getOnepage()->saveBilling($data, $customerAddressId);

if (!isset($result['error'])) {
/* check quote for virtual */
if ($this->getOnepage()->getQuote()->isVirtual()) {
$result['goto_section'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
} elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
$result['goto_section'] = 'shipping_method';
$result['update_section'] = array(
'name' => 'shipping-method',
'html' => $this->_getShippingMethodsHtml()
);

$result['allow_sections'] = array('shipping');
$result['duplicateBillingInfo'] = 'true';
} else {
$result['goto_section'] = 'shipping';
}
}

$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
-----------------------With-----------------------
public function saveBillingAction()
{
if ($this->_expireAjax()) {
return;
}
if ($this->getRequest()->isPost()) {
$postData = $this->getRequest()->getPost('billing', array());
$data = $this->_filterPostData($postData);
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);

if (isset($data['email'])) {
$data['email'] = trim($data['email']);
}
$result = $this->getOnepage()->saveBilling($data, $customerAddressId);

if (!isset($result['error'])) {
/* check quote for virtual */
if ($this->getOnepage()->getQuote()->isVirtual()) {
$result['goto_section'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
} else {
$result['goto_section'] = 'payment';
}
}

$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}



Step 4. app/code/core/Mage/Sales/Model/Service/Quote.php

-------------------------Change this code ----------------
protected function _validate()
{
$helper = Mage::helper('sales');
if (!$this->getQuote()->isVirtual()) {
$address = $this->getQuote()->getShippingAddress();
$addressValidation = $address->validate();
if ($addressValidation !== true) {
Mage::throwException(
$helper->__('Please check shipping address information. %s', implode(' ', $addressValidation))
);
}
$method= $address->getShippingMethod();
$rate = $address->getShippingRateByCode($method);*/
if (!$this->getQuote()->isVirtual() && (!$method || !$rate)) {
Mage::throwException($helper->__('Please specify a shipping method.'));
}
}


---------------------------With------------------------
protected function _validate()
{
$helper = Mage::helper('sales');
if (!$this->getQuote()->isVirtual()) {
$address = $this->getQuote()->getShippingAddress();
$addressValidation = $address->validate();
}



Step: 5. app/design/frontend/base/default/template/checkout/onepage/billing.phtml

remove the code of radio button : line no 173

Step: 6. app/design/frontend/base/default/template/checkout/onepage/progress.phtml
remove the code for hide shipping method block: Your Checkout Progress

Step: 7.


Change Order tamplate which you have created
OR
Change from here:
app/locale/en_US/template/email/sales/order_new.html


Shipping Information:
Shipping Method:

{{var order.getShippingAddress().format('html')}}

{{var order.getShippingDescription()}}

Refer Following url:

http://www.magentocommerce.com/boards/viewthread/76049/

http://www.magentocommerce.com/boards/viewthread/19125/

Onepage Checkout - Remove login in magnto


1.) /app/design/frontend/default/detault/layout/checkout.xml



2: Create local.xml




     
             
           
     



3.) /app/design/frontend/default/default/template/checkout/onepage.phtml







Done :-

Thursday, 5 July 2012

How to increase magento speed


First Step  :- First Off All Delete all Cache And Reindexing Then Start Next Step .....

Open .htacess file of your Magento. Find this code in .htaccess file and Replace

Current Code :-

############################################
## 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

# 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



Replace Code :-

############################################
## 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

# 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



Second Step :-  Find & Replace

Current Code

############################################
## enable resulting html compression

#php_flag zlib.output_compression on


Replace Code

############################################
## enable resulting html compression

php_flag zlib.output_compression on


Save .htaccess file.


Final Step :- 

After Complete  3 Step one time delete all cache and Reindexing.
Check Your Website Speed
Congratulation.

Tuesday, 3 July 2012

How to display random products on home page in Magento

To display random products on home page in Magento Theme you need to follow the below give steps:-
Step 1.
Create a new file called random.phtml at app/design/frontend/default/Your_Theme/template/catalog/random.phtml with the following given code:-



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 
$chosen_category = Mage::getModel('catalog/category')->load($this->getCategoryId());
$_productCollection = $this->getLoadedProductCollection();
$number_of_products = $this->getNumProducts();
if (sizeof($_productCollection) < $number_of_products) {
 $number_of_products = sizeof($_productCollection);
}
$displayed_products = array();
foreach ($_productCollection as $_product) {
 $displayed_products[] = $_product;
}
$random_products = array();
if (sizeof($_productCollection) > 1) {
 $random_products = array_rand($displayed_products, $number_of_products);
} else {
 $random_products = array('0');
}
?>
 if(!$_productCollection->getSize()):?>
<div class="note-msg">
    $this->__('There are no products matching the selection.')?>
div>
 else:?>
 
<div class="main-binder">
  <div class="cms-box">
  <div class="category-title">
      <h2>Random Productsh2>
  div> 
  <div class="category-products">
    <table id="products-grid-table" class="products-grid">
  
 $k=0;
 for ($i=0; $i < $number_of_products; $i++): ?>
  if ($k == 0) { ?>
   <tr class="first odd">
   } if($k==3) { $k=0;  ?> 
   tr><tr class="first odd even">
   } ?>
         <td id="td_$k+1); ?>"  if($k==3){ ?>class="last" } ?> >
  <div class="cms-box">
              <div id="cont_$k+1); ?>">
     <div class="product-name-block">                 
      
      $pname=$this->htmlEscape($displayed_products[$random_products[$i]]->getName());
      ?>
      <h3 class="product-name">      
      <a href="$displayed_products[$random_products[$i]]->getProductUrl()?>" title="$pname; ?>">
                     if(strlen($pname) > 28) {echo substr($pname,0,25)."...";}else {echo $pname;}?>
                    a>h3>
                div>
                <div class="image-box">     
    <a class="product-image" href="$displayed_products[$random_products[$i]]->getProductUrl()?>"> <img src="$this->helper('catalog/image')->init($displayed_products[$random_products[$i]], 'small_image')->resize(140);?>" alt="$this->htmlEscape($displayed_products[$random_products[$i]]->getName())?>" title="$this->htmlEscape($displayed_products[$random_products[$i]]->getName())?>"/> a> 
    div>
 
    <div class="cms-price-box" style=" text-align:center;">
     <span class="regular-price" id="product-price-37">      
      <span class="price" >php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->
     getCurrentCurrencyCode())->getSymbol().$displayed_products[$random_products[$i]]->getPrice(); ?>span>
     span>                      
    div>
    <div class="button-row" style="text-align:center;">
       <button onclick="setLocation('$displayed_products[$random_products[$i]]->getProductUrl();?>')" class="button" type="button"><span><span><span>Detailsspan>span>span>button>                               
     <button onclick="setLocation('$this->getUrl('')."/checkout/cart/add?product=".$displayed_products[$random_products[$i]]->getId()."&qty=1"  ?>')" class="button"><span>php echo $this->__('Add to Cart') ?>span>button>
    div>
              div>
        div>td> 
 
 $k++; ?>
 endfor;?>
tr>
      table>     
    div>
  div>
div>  
 endif;?>
 
 
 Note: Use this blog in magento admin.
 
<p>{{block type="catalog/product_list" category_id="3" num_products="8" template="catalog/random.phtml"}}p>
 
 Note: Category Id will be specific to your Store.