Friday, 6 July 2012

Removing dropdowns from Product List Pager in magnto

Magento styles the “Sort By” and “Show x per page” with a drop down, however for one of our sites we needed to put these into a link list. The change was easier to enact than I thought (or at least by Magento’s standards). So if you want to do it yourself:

1. Open up template/catalog/product/list/toolbar.phtml, and look for the “Sort By” div. Completely replace the select and dropdown options with:
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
<a href=”<?php echo $this->getOrderUrl($_key, ‘asc’) ?>” ><?php echo $this->__($_order) ?></a>
<?php endforeach; ?>

2. In the same file, look for the “Limiter” div and replace with:
<div class=”limiter”>
<label><?php echo $this->__(‘Show’) ?></label>
<?php foreach ($this->getAvailableLimit() as $_key=>$_limit): ?>
<a href=”<?php echo $this->getLimitUrl($_key) ?>”><?php echo $_limit ?></a>
<?php endforeach; ?>
<?php echo $this->__(‘per page’) ?>
</div>
The result:

Remove Category option from Layered Navigation options list in magnto

 
This is what I did to remove the “Category” section from my layered navigation so I wouldnt have any repeat information with the attributes I wanted in the layered navigation.
go to app/design/frontend/default/default/template/catalog/layer and open up view.phtml for edit.
 
<dl id="narrow-by-list"><?php $_filters = $this->getFilters() ?>
<?php 
foreach ($_filters as $_filter): ?>
 <?php 
if($_filter->getItemsCount()): ?>
<?php 
if($_filter->getName() != "Category"){ ?><dt><?php echo $this->__($_filter->getName()) ?></dt>
<
dd><?php echo $_filter->getHtml() ?></dd><?php } endif; ?>
<?php 
endforeach; ?></dl>

Show Category With Image in Magento

For adding of  categories with its  images on homepage od magento  we have to add    block from admininstration cms management either by just putiing the code given below  or making the static block .

{{block type="catalog/navigation" name="catalog.category" 
template="catalog/category/list_category.phtml"}}
 
 And also you need to create a list.phtml file under “/app/design/frontend/default/default/template/catalog/category/list_category.phtml”

<?php foreach ($this->getStoreCategories() as $_category): ?>
 <?php $open = $this->isCategoryActive($_category); ?>
 <?php
$cur_category=Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
if ($immagine = $this->getCurrentCategory()->getImageUrl()):
 ?>
<div style="float:left; padding-right:30px; text-align:center;">
 <div class="linkimage">
 <p>
 <a href="<?php echo $this->getCategoryUrl($_category)?>">
 <img src="<?php echo $immagine ?>"
  alt="<?php echo $this->htmlEscape($this->getCurrentCategory()->getName()) ?>" width="135" height="135" />
 <?php echo $_category->getName()?>
    </a>
    </p>
    </div>
    </div> <?php endif; ?>
    <?php endforeach; ?>

Thursday, 5 July 2012

Onepage Checkout - Remove login in magnto

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

<!-- <block type="checkout/onepage_login" name="checkout.onepage.login" as="login" template="checkout/onepage/login.phtml"/> -->

2: Create local.xml 

  1. <?xml version="1.0"?>
  2. <layout version="0.1.0">
  3. <checkout_onepage_index>
  4.       <reference name="content">
  5.              <! -- Complete process of removing steps is defined here: http://www.magentocommerce.com/wiki/5_-_modules_and_development/checkout/customizing_onepage_checkout_-_remove_shipping_method -->
  6.             <remove name="checkout.onepage.login"/>
  7.       </reference>
  8. </checkout_onepage_index>
  9. </layout>

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

  1. <!-- ADD THIS NEXT LINE!!! -->
  2. <input type="hidden" name="checkout_method" id="login:guest" checked="checked" value="guest"/>
  3.  
  4. <script type="text/javascript">
  5. //<![CDATA[
  6.     var accordion = new Accordion('checkoutSteps', '.head', true);
  7.     <?php if($this->getActiveStep()): ?>
  8.     accordion.openSection('opc-billing');
  9.     <?php endif ?>
  10.  
  11.     var checkout = new Checkout(accordion,{
  12.         progress: '<?php echo $this->getUrl('checkout/onepage/progress') ?>',
  13.         review: '<?php echo $this->getUrl('checkout/onepage/review') ?>',
  14.         saveMethod: '<?php echo $this->getUrl('checkout/onepage/saveMethod') ?>',
  15.         failure: '<?php echo $this->getUrl('checkout/cart') ?>'}
  16.     );
  17.  
  18.     // Go to the next method on start (it will look for the input we added above)
  19.     //IE fix
  20.     var cb = $("login:guest");
  21.     cb.checked = true;
  22.  
  23.     checkout.setMethod();  // MAKE SURE TO ADD THIS LINE!!!
  24. //]]>
  25. </script>
 

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/

Wednesday, 4 July 2012

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  <!-- BOF SIZE CHART --><!-- BOF SIZE CHART -->
2<?php
3  $sizeChartIcon= Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."size-charts/size-chart.gif"; ?>
4            <a onclick="$('size-chart').show();"><?php echo '<img src="%27.$sizeChartIcon.%27" alt="size chart">' ; ?>  </a>
5            <div id="size-chart" style="display:none;"> <?php echo  Mage::app() ->getLayout() ->createBlock('cms/block') ->setBlockId($_product->getAttributeText('size_chart_template')) ->toHtml(); ?></div>
6<!-- EOF SIZE CHART --><!-- EOF SIZE CHART -->

Display special priced products on your Magento homepage

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


<reference name="content">
<remove name="product_list"/>
<remove name="category.products"/>
<block before="-" type="catalog/product" name="home.new" alias="product" template="catalog/product/specials.phtml"> <action method="setProductsCount"><count>9</count></action>
</block>
</reference>
 
Step two:
 
First of all this is the code were that we're going to be using to do this.
 
<?php
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 '<div class="listing-type-grid catalog-listing">';
$_collectionSize = $_productCollection->count();
$i=0; foreach($_productCollection as $_product):
if($i++%3==0)
echo '<ol class="grid-row">';

echo '<li class="item">';
echo '<p class="product-image">';
echo '<a href="'.$_product->getProductUrl().'" title="'.$this->htmlEscape($this->getImageLabel($_product, 'small_image')).'">';
echo '<img src="'.$this->helper('catalog/image')->init($_product, 'small_image')->resize(135, 135).'" width="135" height="135" alt="'.$this->htmlEscape($this->getImageLabel($_product, 'small_image')).'" title="'.$this->htmlEscape($this->getImageLabel($_product, 'small_image')).'" />
</a>
</p>';
echo '<h5><a href="'.$this->getProductUrl().'" title="'.$this->htmlEscape($_product->getName()).'">'.$this->htmlEscape($_product->getName()).'</h5>';

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

<?php if($i%3==0 || $i==$_collectionSize): ?>
</ol>
<?php endif; ?>
<?php endforeach ?>
</div> 

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